baiducloud

package
v0.0.0-...-7df4f84 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 22 Imported by: 3

README

Cluster Autoscaler on BaiduCloud

The cluster autoscaler on BaiduCloud scales worker nodes within any specified autoscaling group. It will run as a Deployment in your cluster. This README will go over some of the necessary steps required to get the cluster autoscaler up and running.

Kubernetes Version

Cluster autoscaler must run on v1.8.6 or greater.

Deployment Specification

1 ASG Setup (min: 1, max: 10, ASG Name: k8s-worker-asg-1)
kubectl apply -f examples/cluster-autoscaler-one-asg.yaml
Multiple ASG Setup (min: 1, max: 10, ASG Name: k8s-worker-asg-1, min: 1, max: 10, ASG Name: k8s-worker-asg-2)
kubectl apply -f examples/cluster-autoscaler-multiple-asg.yaml

Common Notes and Gotchas:

  • By default, cluster autoscaler will not terminate nodes running pods in the kube-system namespace. You can override this default behaviour by passing in the --skip-nodes-with-system-pods=false flag.
  • By default, cluster autoscaler will wait 10 minutes between scale down operations, you can adjust this using the --scale-down-delay flag. E.g. --scale-down-delay=5m to decrease the scale down delay to 5 minutes.

Maintainer

Documentation

Index

Constants

View Source
const (

	// CceUserAgent is a prefix of the http header UserAgent.
	CceUserAgent = "cce-k8s:"
)
View Source
const (
	// GPULabel is the label added to nodes with GPU resource.
	GPULabel = "baidu/nvidia_name"
)

Variables

This section is empty.

Functions

func BuildBaiducloud

BuildBaiducloud builds baiducloud cloud provider, manager etc.

func BuildBaiducloudCloudProvider

func BuildBaiducloudCloudProvider(manager *BaiducloudManager, discoveryOpts cloudprovider.NodeGroupDiscoveryOptions, resourceLimiter *cloudprovider.ResourceLimiter) (cloudprovider.CloudProvider, error)

BuildBaiducloudCloudProvider builds CloudProvider implementation for Baiducloud.

Types

type Asg

type Asg struct {
	BaiducloudRef
	// contains filtered or unexported fields
}

Asg implements NodeGroup interface.

func (*Asg) AtomicIncreaseSize

func (asg *Asg) AtomicIncreaseSize(delta int) error

AtomicIncreaseSize is not implemented.

func (*Asg) Autoprovisioned

func (asg *Asg) Autoprovisioned() bool

Autoprovisioned returns true if the node group is autoprovisioned. An autoprovisioned group was created by CA and can be deleted when scaled to 0.

func (*Asg) Belongs

func (asg *Asg) Belongs(instanceID string) (bool, error)

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

func (*Asg) Create

func (asg *Asg) Create() (cloudprovider.NodeGroup, error)

Create creates the node group on the cloud provider side. Implementation optional.

func (*Asg) Debug

func (asg *Asg) Debug() string

Debug returns a string containing all information regarding this node group.

func (*Asg) DecreaseTargetSize

func (asg *Asg) 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. It is assumed that cloud provider will not delete the existing nodes when there is an option to just decrease the target. Implementation required.

func (*Asg) Delete

func (asg *Asg) 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. Implementation optional.

func (*Asg) DeleteNodes

func (asg *Asg) DeleteNodes(nodes []*apiv1.Node) error

DeleteNodes deletes nodes from this node group. Error is returned either on failure or if the given node doesn't belong to this node group. This function should wait until node group size is updated. Implementation required.

func (*Asg) Exist

func (asg *Asg) 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. Implementation required.

func (*Asg) ForceDeleteNodes

func (asg *Asg) ForceDeleteNodes(nodes []*apiv1.Node) error

ForceDeleteNodes deletes nodes from the group regardless of constraints.

func (*Asg) GetOptions

GetOptions returns NodeGroupAutoscalingOptions that should be used for this particular NodeGroup. Returning a nil will result in using default options.

func (*Asg) Id

func (asg *Asg) Id() string

Id returns an unique identifier of the node group.

func (*Asg) IncreaseSize

func (asg *Asg) IncreaseSize(delta int) error

IncreaseSize increases the size of the node group. To delete a node you need to explicitly name it and use DeleteNode. This function should wait until node group size is updated. Implementation required.

func (*Asg) MaxSize

func (asg *Asg) MaxSize() int

MaxSize returns maximum size of the node group.

func (*Asg) MinSize

func (asg *Asg) MinSize() int

MinSize returns minimum size of the node group.

func (*Asg) Nodes

func (asg *Asg) Nodes() ([]cloudprovider.Instance, error)

Nodes returns a list of all nodes that belong to this node group. It is required that Instance objects returned by this method have Id field set. Other fields are optional.

func (*Asg) TargetSize

func (asg *Asg) TargetSize() (int, error)

TargetSize returns the current target size of the node group. It is possible that the number of nodes in Kubernetes is different at the moment but should be equal to Size() once everything stabilizes (new nodes finish startup and registration or removed nodes are deleted completely). Implementation required.

func (*Asg) TemplateNodeInfo

func (asg *Asg) TemplateNodeInfo() (*framework.NodeInfo, error)

TemplateNodeInfo returns a framework.NodeInfo structure of an empty (as if just started) node. This will be used in scale-up simulations to predict what would a new node look like if a node group was expanded. The returned NodeInfo is expected to have a fully populated Node object, with all of the labels, capacity and allocatable information as well as all pods that are started on the node by default, using manifest (most likely only kube-proxy). Implementation optional.

type BaiducloudManager

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

BaiducloudManager handles baiducloud communication and data caching.

func CreateBaiducloudManager

func CreateBaiducloudManager(configReader io.Reader) (*BaiducloudManager, error)

CreateBaiducloudManager constructs baiducloudManager object.

func (*BaiducloudManager) GetAsgForInstance

func (m *BaiducloudManager) GetAsgForInstance(instanceID string) (*Asg, error)

GetAsgForInstance returns AsgConfig.

func (*BaiducloudManager) GetAsgNodes

func (m *BaiducloudManager) GetAsgNodes(asg *Asg) ([]string, error)

GetAsgNodes returns Asg nodes.

func (*BaiducloudManager) GetAsgSize

func (m *BaiducloudManager) GetAsgSize(asg *Asg) (int64, error)

GetAsgSize gets asg's size.

func (*BaiducloudManager) RegisterAsg

func (m *BaiducloudManager) RegisterAsg(asg *Asg)

RegisterAsg registers asg in the BCE Manager.

func (*BaiducloudManager) ScaleDownCluster

func (m *BaiducloudManager) ScaleDownCluster(instances []string) error

ScaleDownCluster decreases nodes belonging to cluster.

func (*BaiducloudManager) ScaleUpCluster

func (m *BaiducloudManager) ScaleUpCluster(delta int, groupID string) error

ScaleUpCluster scales up cluster.

type BaiducloudRef

type BaiducloudRef struct {
	Name string
}

BaiducloudRef contains a reference to some entity in baiducloud world.

type CloudConfig

type CloudConfig struct {
	ClusterID       string `json:"ClusterId"`
	ClusterName     string `json:"ClusterName"`
	AccessKeyID     string `json:"AccessKeyID"`
	SecretAccessKey string `json:"SecretAccessKey"`
	Region          string `json:"Region"`
	VpcID           string `json:"VpcId"`
	MasterID        string `json:"MasterId"`
	Endpoint        string `json:"Endpoint"`
	NodeIP          string `json:"NodeIP"`
	Debug           bool   `json:"Debug"`
}

CloudConfig is the cloud config file for baiducloud.

Directories

Path Synopsis
baiducloud-sdk-go
bcc
bce
Package bce defined a set of core data structure and functions for Baidu Cloud API.
Package bce defined a set of core data structure and functions for Baidu Cloud API.
blb
cce
eip
util
Package util implements a set of util functions.
Package util implements a set of util functions.
vpc

Jump to

Keyboard shortcuts

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