Documentation ¶
Index ¶
- Constants
- Variables
- func BuildGKE(opts config.AutoscalingOptions, do cloudprovider.NodeGroupDiscoveryOptions, ...) cloudprovider.CloudProvider
- func NewAutoscalingGkeClientV1(client *http.Client, projectId, location, clusterName string) (*autoscalingGkeClientV1, error)
- func NewAutoscalingGkeClientV1beta1(client *http.Client, projectId, location, clusterName string) (*autoscalingGkeClientV1beta1, error)
- type AutoscalingGkeClient
- type Cluster
- type GcpCloudProviderMode
- type GkeCloudProvider
- func (gke *GkeCloudProvider) Cleanup() error
- func (gke *GkeCloudProvider) GetAvailableMachineTypes() ([]string, error)
- func (gke *GkeCloudProvider) GetClusterInfo() (projectId, location, clusterName string)
- func (gke *GkeCloudProvider) GetNodeLocations() []string
- func (gke *GkeCloudProvider) GetResourceLimiter() (*cloudprovider.ResourceLimiter, error)
- func (gke *GkeCloudProvider) Name() string
- func (gke *GkeCloudProvider) NewNodeGroup(machineType string, labels map[string]string, systemLabels map[string]string, ...) (cloudprovider.NodeGroup, error)
- func (gke *GkeCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.NodeGroup, error)
- func (gke *GkeCloudProvider) NodeGroups() []cloudprovider.NodeGroup
- func (gke *GkeCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError)
- func (gke *GkeCloudProvider) Refresh() error
- type GkeManager
- type GkeMig
- func (mig *GkeMig) Autoprovisioned() bool
- func (mig *GkeMig) Belongs(node *apiv1.Node) (bool, error)
- func (mig *GkeMig) Create() (cloudprovider.NodeGroup, error)
- func (mig *GkeMig) Debug() string
- func (mig *GkeMig) DecreaseTargetSize(delta int) error
- func (mig *GkeMig) Delete() error
- func (mig *GkeMig) DeleteNodes(nodes []*apiv1.Node) error
- func (mig *GkeMig) Exist() bool
- func (mig *GkeMig) GceRef() gce.GceRef
- func (mig *GkeMig) Id() string
- func (mig *GkeMig) IncreaseSize(delta int) error
- func (mig *GkeMig) MaxSize() int
- func (mig *GkeMig) MinSize() int
- func (mig *GkeMig) NodePoolName() string
- func (mig *GkeMig) Nodes() ([]cloudprovider.Instance, error)
- func (mig *GkeMig) Spec() *MigSpec
- func (mig *GkeMig) TargetSize() (int, error)
- func (mig *GkeMig) TemplateNodeInfo() (*schedulercache.NodeInfo, error)
- type GkeTemplateBuilder
- type MigSpec
- type NodePool
Constants ¶
const (
// ProviderNameGKE is the name of GKE cloud provider.
ProviderNameGKE = "gke"
)
Variables ¶
var ( // GkeAPIEndpoint overrides default GKE API endpoint for testing. // This flag is outside main as it's only useful for test/development. GkeAPIEndpoint = flag.String("gke-api-endpoint", "", "GKE API endpoint address. This flag is used by developers only. Users shouldn't change this flag.") )
Functions ¶
func BuildGKE ¶
func BuildGKE(opts config.AutoscalingOptions, do cloudprovider.NodeGroupDiscoveryOptions, rl *cloudprovider.ResourceLimiter) cloudprovider.CloudProvider
BuildGKE builds a new GKE cloud provider, manager etc.
Types ¶
type AutoscalingGkeClient ¶
type AutoscalingGkeClient interface { // reading cluster state GetCluster() (Cluster, error) // modifying cluster state DeleteNodePool(string) error CreateNodePool(*GkeMig) error }
AutoscalingGkeClient is used for communicating with GKE API.
type Cluster ¶
type Cluster struct { Locations []string NodePools []NodePool ResourceLimiter *cloudprovider.ResourceLimiter }
Cluster contains cluster's fields we want to use.
type GcpCloudProviderMode ¶
type GcpCloudProviderMode string
GcpCloudProviderMode allows to pass information whether the cluster is in NAP mode.
const ( // 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 GkeCloudProvider ¶
type GkeCloudProvider struct {
// contains filtered or unexported fields
}
GkeCloudProvider implements CloudProvider interface.
func BuildGkeCloudProvider ¶
func BuildGkeCloudProvider(gkeManager GkeManager, resourceLimiter *cloudprovider.ResourceLimiter) (*GkeCloudProvider, error)
BuildGkeCloudProvider builds CloudProvider implementation for GKE.
func (*GkeCloudProvider) Cleanup ¶
func (gke *GkeCloudProvider) Cleanup() error
Cleanup cleans up all resources before the cloud provider is removed
func (*GkeCloudProvider) GetAvailableMachineTypes ¶
func (gke *GkeCloudProvider) GetAvailableMachineTypes() ([]string, error)
GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.
func (*GkeCloudProvider) GetClusterInfo ¶
func (gke *GkeCloudProvider) GetClusterInfo() (projectId, location, clusterName string)
GetClusterInfo returns the project id, location and cluster name.
func (*GkeCloudProvider) GetNodeLocations ¶
func (gke *GkeCloudProvider) GetNodeLocations() []string
GetNodeLocations returns the list of zones in which the cluster has nodes.
func (*GkeCloudProvider) GetResourceLimiter ¶
func (gke *GkeCloudProvider) GetResourceLimiter() (*cloudprovider.ResourceLimiter, error)
GetResourceLimiter returns struct containing limits (max, min) for resources (cores, memory etc.).
func (*GkeCloudProvider) Name ¶
func (gke *GkeCloudProvider) Name() string
Name returns name of the cloud provider.
func (*GkeCloudProvider) NewNodeGroup ¶
func (gke *GkeCloudProvider) 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 (*GkeCloudProvider) NodeGroupForNode ¶
func (gke *GkeCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.NodeGroup, error)
NodeGroupForNode returns the node group for the given node.
func (*GkeCloudProvider) NodeGroups ¶
func (gke *GkeCloudProvider) NodeGroups() []cloudprovider.NodeGroup
NodeGroups returns all node groups configured for this cloud provider.
func (*GkeCloudProvider) Pricing ¶
func (gke *GkeCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError)
Pricing returns pricing model for this cloud provider or error if not available.
func (*GkeCloudProvider) Refresh ¶
func (gke *GkeCloudProvider) 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 GkeManager ¶
type GkeManager interface { // Refresh triggers refresh of cached resources. Refresh() error // Cleanup cleans up open resources before the cloud provider is destroyed, i.e. go routines etc. Cleanup() error // GetLocation returns cluster's location. GetLocation() string // GetProjectId returns id of GCE project to which the cluster belongs. GetProjectId() string // GetClusterName returns the name of the GKE cluster. GetClusterName() string // GetMigs returns a list of registered MIGs. GetMigs() []*gce.MigInformation // GetMigNodes returns mig nodes. GetMigNodes(mig gce.Mig) ([]string, error) // GetMigForInstance returns MigConfig of the given Instance GetMigForInstance(instance *gce.GceRef) (gce.Mig, error) // GetMigTemplateNode returns a template node for MIG. GetMigTemplateNode(mig *GkeMig) (*apiv1.Node, error) // GetMigSize gets MIG size. GetMigSize(mig gce.Mig) (int64, error) // GetNodeLocations returns a list of locations with nodes. GetNodeLocations() []string // GetResourceLimiter returns resource limiter. GetResourceLimiter() (*cloudprovider.ResourceLimiter, error) // SetMigSize sets MIG size. SetMigSize(mig gce.Mig, size int64) error // DeleteInstances deletes the given instances. All instances must be controlled by the same MIG. DeleteInstances(instances []*gce.GceRef) error // CreateNodePool creates a MIG based on blueprint and returns the newly created MIG. CreateNodePool(mig *GkeMig) (*GkeMig, error) // DeleteNodePool deletes a MIG from cloud provider. DeleteNodePool(toBeRemoved *GkeMig) error }
GkeManager handles GCE and GKE communication and data caching.
func CreateGkeManager ¶
func CreateGkeManager(configReader io.Reader, mode GcpCloudProviderMode, clusterName string, regional bool) (GkeManager, error)
CreateGkeManager constructs GkeManager object.
type GkeMig ¶
type GkeMig struct {
// contains filtered or unexported fields
}
GkeMig represents the GKE Managed Instance Group implementation of a NodeGroup.
func (*GkeMig) Autoprovisioned ¶
Autoprovisioned returns true if the node group is autoprovisioned.
func (*GkeMig) Create ¶
func (mig *GkeMig) Create() (cloudprovider.NodeGroup, error)
Create creates the node group on the cloud provider side.
func (*GkeMig) DecreaseTargetSize ¶
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 (*GkeMig) Delete ¶
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 (*GkeMig) DeleteNodes ¶
DeleteNodes deletes the nodes from the group.
func (*GkeMig) Exist ¶
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 (*GkeMig) IncreaseSize ¶
IncreaseSize increases Mig size
func (*GkeMig) NodePoolName ¶
NodePoolName returns the name of the GKE node pool this Mig belongs to.
func (*GkeMig) Nodes ¶
func (mig *GkeMig) Nodes() ([]cloudprovider.Instance, error)
Nodes returns a list of all nodes that belong to this node group.
func (*GkeMig) TargetSize ¶
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 (*GkeMig) TemplateNodeInfo ¶
func (mig *GkeMig) TemplateNodeInfo() (*schedulercache.NodeInfo, error)
TemplateNodeInfo returns a node template for this node group.
type GkeTemplateBuilder ¶
type GkeTemplateBuilder struct { gce.GceTemplateBuilder // contains filtered or unexported fields }
GkeTemplateBuilder builds templates for GKE cloud provider.
func (*GkeTemplateBuilder) BuildNodeFromMigSpec ¶
func (t *GkeTemplateBuilder) BuildNodeFromMigSpec(mig *GkeMig, cpu int64, mem int64) (*apiv1.Node, error)
BuildNodeFromMigSpec builds node based on MIG's spec.