gke

package
v0.0.0-...-2908132 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderNameGKE is the name of GKE cloud provider.
	ProviderNameGKE = "gke"
)

Variables

View Source
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 NewAutoscalingGkeClientV1

func NewAutoscalingGkeClientV1(client *http.Client, projectId, location, clusterName string) (*autoscalingGkeClientV1, error)

NewAutoscalingGkeClientV1 creates a new client for communicating with GKE v1 API.

func NewAutoscalingGkeClientV1beta1

func NewAutoscalingGkeClientV1beta1(client *http.Client, projectId, location, clusterName string) (*autoscalingGkeClientV1beta1, error)

NewAutoscalingGkeClientV1beta1 creates a new client for communicating with GKE v1beta1 API.

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

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 {
	// GetMigSize gets MIG size.
	GetMigSize(mig gce.Mig) (int64, 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
	// GetMigForInstance returns MigConfig of the given Instance
	GetMigForInstance(instance *gce.GceRef) (gce.Mig, error)
	// GetMigNodes returns mig nodes.
	GetMigNodes(mig gce.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
	GetMigs() []*gce.MigInformation
	CreateNodePool(mig *GkeMig) (*GkeMig, error)
	DeleteNodePool(toBeRemoved *GkeMig) error
	GetLocation() string
	GetProjectId() string
	GetClusterName() string
	GetMigTemplateNode(mig *GkeMig) (*apiv1.Node, error)
	GetNodeLocations() []string
}

GkeManager handles gce 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

func (mig *GkeMig) Autoprovisioned() bool

Autoprovisioned returns true if the node group is autoprovisioned.

func (*GkeMig) Belongs

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

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

func (*GkeMig) Create

func (mig *GkeMig) Create() (cloudprovider.NodeGroup, error)

Create creates the node group on the cloud provider side.

func (*GkeMig) Debug

func (mig *GkeMig) Debug() string

Debug returns a debug string for the Mig.

func (*GkeMig) DecreaseTargetSize

func (mig *GkeMig) 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 (*GkeMig) Delete

func (mig *GkeMig) 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 (*GkeMig) DeleteNodes

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

DeleteNodes deletes the nodes from the group.

func (*GkeMig) Exist

func (mig *GkeMig) 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 (*GkeMig) GceRef

func (mig *GkeMig) GceRef() gce.GceRef

GceRef returns Mig's GceRef

func (*GkeMig) Id

func (mig *GkeMig) Id() string

Id returns mig url.

func (*GkeMig) IncreaseSize

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

IncreaseSize increases Mig size

func (*GkeMig) MaxSize

func (mig *GkeMig) MaxSize() int

MaxSize returns maximum size of the node group.

func (*GkeMig) MinSize

func (mig *GkeMig) MinSize() int

MinSize returns minimum size of the node group.

func (*GkeMig) NodePoolName

func (mig *GkeMig) NodePoolName() string

NodePoolName returns the name of the GKE node pool this Mig belongs to.

func (*GkeMig) Nodes

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

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

func (*GkeMig) Spec

func (mig *GkeMig) Spec() *MigSpec

Spec returns specification of the Mig.

func (*GkeMig) TargetSize

func (mig *GkeMig) 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 (*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.

type MigSpec

type MigSpec struct {
	MachineType    string
	Labels         map[string]string
	Taints         []apiv1.Taint
	ExtraResources map[string]resource.Quantity
}

MigSpec contains information about what machines in a MIG look like.

type NodePool

type NodePool struct {
	Name              string
	InstanceGroupUrls []string
	Autoscaled        bool
	MinNodeCount      int64
	MaxNodeCount      int64
	Autoprovisioned   bool
}

NodePool contains node pool's fields we want to use.

Jump to

Keyboard shortcuts

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