provider

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AWSAccessKey                 = "/var/keys/service-key.json"
	AWSAccessKeyID               = "AWS_ACCESS_KEY_ID"
	AWSSecretAccessKey           = "AWS_SECRET_ACCESS_KEY"
	AWSClusterIDTagKey           = "KubernetesCluster"
	AWSGroupNameTagKey           = "aws:autoscaling:groupName"
	AWSRoleMasterTagKey          = "k8s.io/role/master"
	AWSRoleNodeTagKey            = "k8s.io/role/node"
	AWSNodeGroupPreviousKey      = "cluster.turndown.previous"
	AutoScalingGroupResourceType = "auto-scaling-group"

	AWSDefaultMachineType = "t2.medium"
	AWSDefaultDiskType    = "gp2"
	AWSDefaultDiskSizeGB  = 64
)
View Source
const (
	KopsClusterTag       = "KubernetesCluster"
	KopsClusterNameTag   = "Name"
	KopsAutoScalerIGTag  = "k8s.io/cluster-autoscaler/node-template/label/kops.k8s.io/instancegroup"
	KopsRoleNodeTag      = "k8s.io/role/node"
	KopsInstanceGroupTag = "kops.k8s.io/instancegroup"
	KopsEnabled          = "1"
)
View Source
const (
	LabelGKENodePool      = "cloud.google.com/gke-nodepool"
	GKECredsEnvVar        = "GOOGLE_APPLICATION_CREDENTIALS"
	GKEAuthServiceAccount = "/var/keys/service-key.json"

	GKEDefaultMachineType = "n1-standard-1"
	GKEDefaultDiskType    = "pd-standard"
	GKEDefaultDiskSizeGB  = 100
)
View Source
const (
	KubecostTurndownUserAgent = "cluster-turndown"
	GKEMetaDataProjectIDKey   = "projectid"
	GKEMetaDataZoneKey        = "zone"
	GKEMetaDataMasterZoneKey  = "master-zone"
	GKEMetaDataClusterNameKey = "cluster-name"
)
View Source
const (
	LabelEKSNodePool = "eks.amazonaws.com/nodegroup"
)

Variables

This section is empty.

Functions

func GetAWSDefaultBlockDeviceMappings

func GetAWSDefaultBlockDeviceMappings(diskType string, diskSizeGB int64) []*autoscaling.BlockDeviceMapping

func GetAWSInstanceMonitoringDefaults

func GetAWSInstanceMonitoringDefaults() *autoscaling.InstanceMonitoring

func GetGKEDefaultMetadata

func GetGKEDefaultMetadata() map[string]string

GetGKEDefaultMetadata returns the default metadata used when creating a new node pool

func GetGKEDefaultNodeManagement

func GetGKEDefaultNodeManagement() *container.NodeManagement

GetGKEDefaultNodeManagement returns the default nod management used when creating a new node pool

func GetGKEDefaultOAuthScopes

func GetGKEDefaultOAuthScopes() []string

GetGKEDefaultOAuthScopes returns the default oauth scopes used when creating a new node pool

func GetKopsInstanceGroupTags

func GetKopsInstanceGroupTags(clusterName, groupName string) map[string]string

GetKopsInstanceGroupTags returns a map of the default kops tags for an autoscaling group

func GetKopsInstanceGroupYaml

func GetKopsInstanceGroupYaml(clusterName, groupName, image, machineType string, minSize, maxSize int64, subnets []string) (string, error)

GetKopsInstanceGroupYaml templates the provided parameter into an InstanceGroup, then encodes into yaml

Types

type AWSAccessKeyFile

type AWSAccessKeyFile struct {
	AccessKeyID     string `json:"aws_access_key_id"`
	SecretAccessKey string `json:"aws_secret_access_key"`
}

Access

type AWSClusterData

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

Container for cluster specific data and configurations

type AWSClusterProvider

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

ClusterProvider for AWS

func (*AWSClusterProvider) CreateAutoScalingNodePool

func (p *AWSClusterProvider) CreateAutoScalingNodePool(c context.Context, name, machineType string, minNodes, nodeCount, maxNodes int32, diskType string, diskSizeGB int32, labels map[string]string) error

CreateAutoScalingNodePool creates a new autoscaling node pool. The semantics behind autoscaling depend on the provider.

func (*AWSClusterProvider) CreateNodePool

func (p *AWSClusterProvider) CreateNodePool(c context.Context, name, machineType string, nodeCount int32, diskType string, diskSizeGB int32, labels map[string]string) error

Creates a new NodePool for a specific parameter list using a kops driven bootstrap.

func (*AWSClusterProvider) CreateOrUpdateTags

func (p *AWSClusterProvider) CreateOrUpdateTags(c context.Context, nodePool NodePool, updateNodes bool, tags map[string]string) error

CreateOrUpdateTags creates or updates the tags for NodePool instances.

func (*AWSClusterProvider) DeleteNodePool

func (p *AWSClusterProvider) DeleteNodePool(c context.Context, nodePool NodePool) error

func (*AWSClusterProvider) DeleteTags

func (p *AWSClusterProvider) DeleteTags(c context.Context, nodePool NodePool, keys []string) error

DeleteTags deletes the tags by key on a NodePool instance.

func (*AWSClusterProvider) GetNodePoolName

func (p *AWSClusterProvider) GetNodePoolName(node *v1.Node) string

GetNodePoolName returns the name of a NodePool for a specific kubernetes node.

func (*AWSClusterProvider) GetNodePools

func (p *AWSClusterProvider) GetNodePools() ([]NodePool, error)

GetNodePools for AWS needs to do a bit more work to acquire a list of "correct" node pools. Since the asusmption is that we're working with kops, a specific region could have many autoscaling groups, so we'll need to refine the list down to the groups associated with kubernetes nodes.

func (*AWSClusterProvider) GetNodesFor

func (p *AWSClusterProvider) GetNodesFor(np NodePool) ([]*v1.Node, error)

GetNodePools loads all of the provider NodePools in a cluster and returns them.

func (*AWSClusterProvider) IsNodePool

func (p *AWSClusterProvider) IsNodePool(name string) bool

IsNodePool determines if there is a node pool with the name or not.

func (*AWSClusterProvider) UpdateNodePoolSize

func (p *AWSClusterProvider) UpdateNodePoolSize(c context.Context, nodePool NodePool, size int32) error

Updates a node pool size to the size parameter.

func (*AWSClusterProvider) UpdateNodePoolSizes

func (p *AWSClusterProvider) UpdateNodePoolSizes(c context.Context, nodePools []NodePool, size int32) error

Updates the node pool sizes for all the provided node pools to the size parameter.

type AWSNodePool

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

AWS NodePool based on AutoScalingGroup

func (*AWSNodePool) AutoScaling

func (np *AWSNodePool) AutoScaling() bool

func (*AWSNodePool) ClusterID

func (np *AWSNodePool) ClusterID() string

func (*AWSNodePool) IsMaster

func (np *AWSNodePool) IsMaster() bool

func (*AWSNodePool) MachineType

func (np *AWSNodePool) MachineType() string

func (*AWSNodePool) MaxNodes

func (np *AWSNodePool) MaxNodes() int32

func (*AWSNodePool) MinNodes

func (np *AWSNodePool) MinNodes() int32

func (*AWSNodePool) Name

func (np *AWSNodePool) Name() string

func (*AWSNodePool) NodeCount

func (np *AWSNodePool) NodeCount() int32

func (*AWSNodePool) Project

func (np *AWSNodePool) Project() string

func (*AWSNodePool) Tags

func (np *AWSNodePool) Tags() map[string]string

func (*AWSNodePool) Zone

func (np *AWSNodePool) Zone() string

type ClusterProvider

type ClusterProvider interface {
	// IsNodePool determines if there is a node pool with the name or not.
	IsNodePool(name string) bool

	// GetNodePoolName returns the name of a NodePool for a specific kubernetes node.
	GetNodePoolName(node *v1.Node) string

	// GetNodesFor returns a slice of kubernetes Node instances for the NodePool instance provided.
	GetNodesFor(np NodePool) ([]*v1.Node, error)

	// GetNodePools loads all of the provider NodePools in a cluster and returns them.
	GetNodePools() ([]NodePool, error)

	// CreateNodePool creates a new node pool with the provided specs.
	CreateNodePool(c context.Context, name, machineType string, nodeCount int32, diskType string, diskSizeGB int32, labels map[string]string) error

	// CreateAutoScalingNodePool creates a new autoscaling node pool. The semantics behind autoscaling depend on the provider.
	CreateAutoScalingNodePool(c context.Context, name, machineType string, minNodes, nodeCount, maxNodes int32, diskType string, diskSizeGB int32, labels map[string]string) error

	// UpdateNodePoolSize updates the number of nodes in a NodePool
	UpdateNodePoolSize(c context.Context, nodePool NodePool, size int32) error

	// UpdateNodePoolSizes updates the number of nodes in multiple NodePool instances.
	UpdateNodePoolSizes(c context.Context, nodePools []NodePool, size int32) error

	// DeleteNodePool deletes the NodePool.
	DeleteNodePool(c context.Context, nodePool NodePool) error

	// CreateOrUpdateTags creates or updates the tags for NodePool instances.
	CreateOrUpdateTags(c context.Context, nodePool NodePool, updateNodes bool, tags map[string]string) error

	// DeleteTags deletes the tags by key on a NodePool instance.
	DeleteTags(c context.Context, nodePool NodePool, keys []string) error
}

ClusterProvider contains methods used to manage cluster node resources

func NewAWSClusterProvider

func NewAWSClusterProvider(kubernetes kubernetes.Interface) (ClusterProvider, error)

NewAWSClusterProvider creates a new AWSClusterProvider instance as the ClusterProvider

func NewClusterProvider

func NewClusterProvider(client kubernetes.Interface) (ClusterProvider, error)

NewClusterProvider is a ClusterProvider factory method that uses the kubernetes client to determine the provider and create the correct implementation.

func NewEKSClusterProvider

func NewEKSClusterProvider(kubernetes kubernetes.Interface) (ClusterProvider, error)

NewEKSClusterProvider creates a new EKSClusterProvider instance as the ClusterProvider

func NewGKEClusterProvider

func NewGKEClusterProvider(kubernetes kubernetes.Interface) (ClusterProvider, error)

NewGKEClusterProvider creates a new GKEClusterProvider instance as the ClusterProvider

type EKSClusterData

type EKSClusterData struct {
	ClusterName string
	NodeRole    string
	SubnetIDs   []string
	Cluster     *eks.Cluster
}

EKSClusterData is used to store cluster specific data

type EKSClusterProvider

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

ClusterProvider implementation for EKS

func (*EKSClusterProvider) CreateAutoScalingNodePool

func (p *EKSClusterProvider) CreateAutoScalingNodePool(c context.Context, name, machineType string, minNodes, nodeCount, maxNodes int32, diskType string, diskSizeGB int32, labels map[string]string) error

CreateAutoScalingNodePool creates a new autoscaling node pool. The semantics behind autoscaling depend on the provider.

func (*EKSClusterProvider) CreateNodePool

func (p *EKSClusterProvider) CreateNodePool(c context.Context, name, machineType string, nodeCount int32, diskType string, diskSizeGB int32, labels map[string]string) error

CreateNodePool creates a new node pool with the provided specs.

func (*EKSClusterProvider) CreateOrUpdateTags

func (p *EKSClusterProvider) CreateOrUpdateTags(c context.Context, nodePool NodePool, updateNodes bool, tags map[string]string) error

CreateOrUpdateTags creates or updates the tags for NodePool instances.

func (*EKSClusterProvider) DeleteNodePool

func (p *EKSClusterProvider) DeleteNodePool(c context.Context, nodePool NodePool) error

DeleteNodePool deletes the NodePool.

func (*EKSClusterProvider) DeleteTags

func (p *EKSClusterProvider) DeleteTags(c context.Context, nodePool NodePool, keys []string) error

DeleteTags deletes the tags by key on a NodePool instance.

func (*EKSClusterProvider) GetNodePoolName

func (p *EKSClusterProvider) GetNodePoolName(node *v1.Node) string

GetNodePoolName returns the name of a NodePool for a specific kubernetes node.

func (*EKSClusterProvider) GetNodePools

func (p *EKSClusterProvider) GetNodePools() ([]NodePool, error)

GetNodePools loads all of the provider NodePools in a cluster and returns them.

func (*EKSClusterProvider) GetNodesFor

func (p *EKSClusterProvider) GetNodesFor(np NodePool) ([]*v1.Node, error)

GetNodesFor returns a slice of kubernetes Node instances for the NodePool instance provided.

func (*EKSClusterProvider) IsNodePool

func (p *EKSClusterProvider) IsNodePool(name string) bool

IsNodePool determines if there is a node pool with the name or not.

func (*EKSClusterProvider) UpdateNodePoolSize

func (p *EKSClusterProvider) UpdateNodePoolSize(c context.Context, nodePool NodePool, size int32) error

UpdateNodePoolSize updates the number of nodes in a NodePool

func (*EKSClusterProvider) UpdateNodePoolSizes

func (p *EKSClusterProvider) UpdateNodePoolSizes(c context.Context, nodePools []NodePool, size int32) error

UpdateNodePoolSizes updates the number of nodes in multiple NodePool instances.

type EKSNodePool

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

NodePool contains a node pool identifier and the initial number of nodes in the pool

func (*EKSNodePool) AutoScaling

func (np *EKSNodePool) AutoScaling() bool

func (*EKSNodePool) ClusterID

func (np *EKSNodePool) ClusterID() string

func (*EKSNodePool) IsMaster

func (np *EKSNodePool) IsMaster() bool

func (*EKSNodePool) MachineType

func (np *EKSNodePool) MachineType() string

func (*EKSNodePool) MaxNodes

func (np *EKSNodePool) MaxNodes() int32

func (*EKSNodePool) MinNodes

func (np *EKSNodePool) MinNodes() int32

func (*EKSNodePool) Name

func (np *EKSNodePool) Name() string

func (*EKSNodePool) NodeCount

func (np *EKSNodePool) NodeCount() int32

func (*EKSNodePool) Project

func (np *EKSNodePool) Project() string

func (*EKSNodePool) Tags

func (np *EKSNodePool) Tags() map[string]string

func (*EKSNodePool) Zone

func (np *EKSNodePool) Zone() string

type GKEClusterProvider

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

ClusterProvider implementation for GKE

func (*GKEClusterProvider) CreateAutoScalingNodePool

func (p *GKEClusterProvider) CreateAutoScalingNodePool(c context.Context, name, machineType string, minNodes, nodeCount, maxNodes int32, diskType string, diskSizeGB int32, labels map[string]string) error

CreateAutoScalingNodePool creates a new autoscaling node pool. The semantics behind autoscaling depend on the provider.

func (*GKEClusterProvider) CreateNodePool

func (p *GKEClusterProvider) CreateNodePool(c context.Context, name, machineType string, nodeCount int32, diskType string, diskSizeGB int32, labels map[string]string) error

CreateNodePool creates a new node pool with the provided specs.

func (*GKEClusterProvider) CreateOrUpdateTags

func (p *GKEClusterProvider) CreateOrUpdateTags(c context.Context, nodePool NodePool, updateNodes bool, tags map[string]string) error

CreateOrUpdateTags creates or updates the tags for NodePool instances.

func (*GKEClusterProvider) DeleteNodePool

func (p *GKEClusterProvider) DeleteNodePool(c context.Context, nodePool NodePool) error

DeleteNodePool deletes the NodePool.

func (*GKEClusterProvider) DeleteTags

func (p *GKEClusterProvider) DeleteTags(c context.Context, nodePool NodePool, keys []string) error

DeleteTags deletes the tags by key on a NodePool instance.

func (*GKEClusterProvider) GetNodePoolName

func (p *GKEClusterProvider) GetNodePoolName(node *v1.Node) string

GetNodePoolName returns the name of a NodePool for a specific kubernetes node.

func (*GKEClusterProvider) GetNodePools

func (p *GKEClusterProvider) GetNodePools() ([]NodePool, error)

GetNodePools loads all of the provider NodePools in a cluster and returns them.

func (*GKEClusterProvider) GetNodesFor

func (p *GKEClusterProvider) GetNodesFor(np NodePool) ([]*v1.Node, error)

GetNodesFor returns a slice of kubernetes Node instances for the NodePool instance provided.

func (*GKEClusterProvider) IsNodePool

func (p *GKEClusterProvider) IsNodePool(name string) bool

IsNodePool determines if there is a node pool with the name or not.

func (*GKEClusterProvider) UpdateNodePoolSize

func (p *GKEClusterProvider) UpdateNodePoolSize(c context.Context, nodePool NodePool, size int32) error

UpdateNodePoolSize updates the number of nodes in a NodePool

func (*GKEClusterProvider) UpdateNodePoolSizes

func (p *GKEClusterProvider) UpdateNodePoolSizes(c context.Context, nodePools []NodePool, size int32) error

UpdateNodePoolSizes updates the number of nodes in multiple NodePool instances.

type GKEMetaData

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

func NewGKEMetaData

func NewGKEMetaData() *GKEMetaData

func (*GKEMetaData) GetClusterID

func (md *GKEMetaData) GetClusterID() string

func (*GKEMetaData) GetMasterZone

func (md *GKEMetaData) GetMasterZone() string

func (*GKEMetaData) GetProjectID

func (md *GKEMetaData) GetProjectID() string

func (*GKEMetaData) GetZone

func (md *GKEMetaData) GetZone() string

type GKENodePool

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

NodePool contains a node pool identifier and the initial number of nodes in the pool

func (*GKENodePool) AutoScaling

func (np *GKENodePool) AutoScaling() bool

func (*GKENodePool) ClusterID

func (np *GKENodePool) ClusterID() string

func (*GKENodePool) IsMaster

func (np *GKENodePool) IsMaster() bool

func (*GKENodePool) MachineType

func (np *GKENodePool) MachineType() string

func (*GKENodePool) MaxNodes

func (np *GKENodePool) MaxNodes() int32

func (*GKENodePool) MinNodes

func (np *GKENodePool) MinNodes() int32

func (*GKENodePool) Name

func (np *GKENodePool) Name() string

func (*GKENodePool) NodeCount

func (np *GKENodePool) NodeCount() int32

func (*GKENodePool) Project

func (np *GKENodePool) Project() string

func (*GKENodePool) Tags

func (np *GKENodePool) Tags() map[string]string

func (*GKENodePool) Zone

func (np *GKENodePool) Zone() string

type KopsInstanceGroup

type KopsInstanceGroup struct {
	APIVersion string                     `yaml:"apiVersion"`
	Kind       string                     `yaml:"kind"`
	Metadata   *KopsInstanceGroupMetaData `yaml:"metadata"`
	Spec       *KopsInstanceGroupSpec     `yaml:"spec"`
}

Kops InstanceGroup

type KopsInstanceGroupMetaData

type KopsInstanceGroupMetaData struct {
	CreationTimestamp metav1.Time       `yaml:"creationTimestamp"`
	Labels            map[string]string `yaml:"labels"`
	Name              string            `yaml:"name"`
}

Kops InstanceGroup MetaData

type KopsInstanceGroupSpec

type KopsInstanceGroupSpec struct {
	Image       string            `yaml:"image"`
	MachineType string            `yaml:"machineType"`
	MaxSize     int64             `yaml:"maxSize"`
	MinSize     int64             `yaml:"minSize"`
	NodeLabels  map[string]string `yaml:"nodeLabels"`
	Role        string            `yaml:"role"`
	Subnets     []string          `yaml:"subnets"`
}

Kops InstanceGroup Spec

type NodePool

type NodePool interface {
	Name() string
	Project() string
	Zone() string
	ClusterID() string
	MinNodes() int32
	MaxNodes() int32
	NodeCount() int32
	AutoScaling() bool
	MachineType() string
	Tags() map[string]string
	IsMaster() bool
}

NodePool is an implementation prototype that represents a collection of nodes.

type UserAgentTransport

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

func (UserAgentTransport) RoundTrip

func (t UserAgentTransport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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