gce

package
v0.0.0-...-e8de369 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2018 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderNameGCE = "gce"
	ProviderNameGKE = "gke"
)

The 'GCE' cloud provider actually implements both the GCE and GKE providers.

Variables

This section is empty.

Functions

func GenerateInstanceUrl

func GenerateInstanceUrl(project, zone, name string) string

GenerateInstanceUrl generates url for instance.

func GenerateMigUrl

func GenerateMigUrl(project, zone, name string) string

GenerateMigUrl generates url for instance.

func ParseInstanceUrl

func ParseInstanceUrl(url string) (project string, zone string, name string, err error)

ParseInstanceUrl expects url in format: https://content.googleapis.com/compute/v1/projects/<project-id>/zones/<zone>/instances/<name>

func ParseMigUrl

func ParseMigUrl(url string) (project string, zone string, name string, err error)

ParseMigUrl expects url in format: https://content.googleapis.com/compute/v1/projects/<project-id>/zones/<zone>/instanceGroups/<name>

Types

type GceCloudProvider

type GceCloudProvider struct {
	// contains filtered or unexported fields
}

GceCloudProvider implements CloudProvider interface.

func BuildGceCloudProvider

func BuildGceCloudProvider(gceManager GceManager, resourceLimiter *cloudprovider.ResourceLimiter) (*GceCloudProvider, error)

BuildGceCloudProvider builds CloudProvider implementation for GCE.

func (*GceCloudProvider) Cleanup

func (gce *GceCloudProvider) Cleanup() error

Cleanup cleans up all resources before the cloud provider is removed

func (*GceCloudProvider) GetAvailableMachineTypes

func (gce *GceCloudProvider) GetAvailableMachineTypes() ([]string, error)

GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.

func (*GceCloudProvider) GetResourceLimiter

func (gce *GceCloudProvider) GetResourceLimiter() (*cloudprovider.ResourceLimiter, error)

GetResourceLimiter returns struct containing limits (max, min) for resources (cores, memory etc.).

func (*GceCloudProvider) Name

func (gce *GceCloudProvider) Name() string

Name returns name of the cloud provider.

func (*GceCloudProvider) NewNodeGroup

func (gce *GceCloudProvider) NewNodeGroup(machineType string, labels map[string]string, systemLabels map[string]string,
	taints []apiv1.Taint, extraResources map[string]resource.Quantity) (cloudprovider.NodeGroup, error)

NewNodeGroup builds a theoretical node group based on the node definition provided. The node group is not automatically created on the cloud provider side. The node group is not returned by NodeGroups() until it is created.

func (*GceCloudProvider) NodeGroupForNode

func (gce *GceCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.NodeGroup, error)

NodeGroupForNode returns the node group for the given node.

func (*GceCloudProvider) NodeGroups

func (gce *GceCloudProvider) NodeGroups() []cloudprovider.NodeGroup

NodeGroups returns all node groups configured for this cloud provider.

func (*GceCloudProvider) Pricing

Pricing returns pricing model for this cloud provider or error if not available.

func (*GceCloudProvider) Refresh

func (gce *GceCloudProvider) Refresh() error

Refresh is called before every main loop and can be used to dynamically update cloud provider state. In particular the list of node groups returned by NodeGroups can change as a result of CloudProvider.Refresh().

type GceManager

type GceManager interface {
	// RegisterMig registers mig in GceManager. Returns true if the node group didn't exist before.
	RegisterMig(mig *Mig) bool
	// UnregisterMig unregisters mig in GceManager. Returns true if the node group has been removed.
	UnregisterMig(toBeRemoved *Mig) bool
	// GetMigSize gets MIG size.
	GetMigSize(mig *Mig) (int64, error)
	// SetMigSize sets MIG size.
	SetMigSize(mig *Mig, size int64) error
	// DeleteInstances deletes the given instances. All instances must be controlled by the same MIG.
	DeleteInstances(instances []*GceRef) error
	// GetMigForInstance returns MigConfig of the given Instance
	GetMigForInstance(instance *GceRef) (*Mig, error)
	// GetMigNodes returns mig nodes.
	GetMigNodes(mig *Mig) ([]string, error)
	// Refresh updates config by calling GKE API (in GKE mode only).
	Refresh() error
	// GetResourceLimiter returns resource limiter.
	GetResourceLimiter() (*cloudprovider.ResourceLimiter, error)
	// Cleanup cleans up open resources before the cloud provider is destroyed, i.e. go routines etc.
	Cleanup() error
	// contains filtered or unexported methods
}

GceManager handles gce communication and data caching.

func CreateGceManager

func CreateGceManager(configReader io.Reader, mode GcpCloudProviderMode, clusterName string, discoveryOpts cloudprovider.NodeGroupDiscoveryOptions, regional bool) (GceManager, error)

CreateGceManager constructs gceManager object.

type GcePriceModel

type GcePriceModel struct {
}

GcePriceModel implements PriceModel interface for GCE.

func (*GcePriceModel) NodePrice

func (model *GcePriceModel) NodePrice(node *apiv1.Node, startTime time.Time, endTime time.Time) (float64, error)

NodePrice returns a price of running the given node for a given period of time. All prices are in USD.

func (*GcePriceModel) PodPrice

func (model *GcePriceModel) PodPrice(pod *apiv1.Pod, startTime time.Time, endTime time.Time) (float64, error)

PodPrice returns a theoretical minimum price of running a pod for a given period of time on a perfectly matching machine.

type GceRef

type GceRef struct {
	Project string
	Zone    string
	Name    string
}

GceRef contains s reference to some entity in GCE/GKE world.

func GceRefFromProviderId

func GceRefFromProviderId(id string) (*GceRef, error)

GceRefFromProviderId creates InstanceConfig object from provider id which must be in format: gce://<project-id>/<zone>/<name> TODO(piosz): add better check whether the id is correct

type GcpCloudProviderMode

type GcpCloudProviderMode string

GcpCloudProviderMode allows to pass information whether the cluster is GCE or GKE.

const (
	// ModeGCE means that the cluster is running on gce (or using the legacy gke setup).
	ModeGCE GcpCloudProviderMode = "gce"

	// ModeGKE means that the cluster is running
	ModeGKE GcpCloudProviderMode = "gke"

	// ModeGKENAP means that the cluster is running on GKE with autoprovisioning enabled.
	// TODO(maciekpytel): remove this when NAP API is available in normal client
	ModeGKENAP GcpCloudProviderMode = "gke_nap"
)

type Mig

type Mig struct {
	GceRef
	// contains filtered or unexported fields
}

Mig implements NodeGroup interface.

func (*Mig) Autoprovisioned

func (mig *Mig) Autoprovisioned() bool

Autoprovisioned returns true if the node group is autoprovisioned.

func (*Mig) Belongs

func (mig *Mig) Belongs(node *apiv1.Node) (bool, error)

Belongs returns true if the given node belongs to the NodeGroup.

func (*Mig) Create

func (mig *Mig) Create() error

Create creates the node group on the cloud provider side.

func (*Mig) Debug

func (mig *Mig) Debug() string

Debug returns a debug string for the Mig.

func (*Mig) DecreaseTargetSize

func (mig *Mig) DecreaseTargetSize(delta int) error

DecreaseTargetSize decreases the target size of the node group. This function doesn't permit to delete any existing node and can be used only to reduce the request for new nodes that have not been yet fulfilled. Delta should be negative.

func (*Mig) Delete

func (mig *Mig) Delete() error

Delete deletes the node group on the cloud provider side. This will be executed only for autoprovisioned node groups, once their size drops to 0.

func (*Mig) DeleteNodes

func (mig *Mig) DeleteNodes(nodes []*apiv1.Node) error

DeleteNodes deletes the nodes from the group.

func (*Mig) Exist

func (mig *Mig) Exist() bool

Exist checks if the node group really exists on the cloud provider side. Allows to tell the theoretical node group from the real one.

func (*Mig) Id

func (mig *Mig) Id() string

Id returns mig url.

func (*Mig) IncreaseSize

func (mig *Mig) IncreaseSize(delta int) error

IncreaseSize increases Mig size

func (*Mig) MaxSize

func (mig *Mig) MaxSize() int

MaxSize returns maximum size of the node group.

func (*Mig) MinSize

func (mig *Mig) MinSize() int

MinSize returns minimum size of the node group.

func (*Mig) Nodes

func (mig *Mig) Nodes() ([]string, error)

Nodes returns a list of all nodes that belong to this node group.

func (*Mig) TargetSize

func (mig *Mig) TargetSize() (int, error)

TargetSize returns the current TARGET size of the node group. It is possible that the number is different from the number of nodes registered in Kubernetes.

func (*Mig) TemplateNodeInfo

func (mig *Mig) TemplateNodeInfo() (*schedulercache.NodeInfo, error)

TemplateNodeInfo returns a node template for this node group.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL