linode

package
v0.0.0-...-ae22146 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

Cluster Autoscaler for Linode

⚠️ The Linode Cluster Autoscaler has been deprecated and will be removed some time in 2025. This implementation has only ever scaled the Linode Kubernetes Engine (LKE) deployments and this product has had native autoscaling for years. This implementation is thus redundant.

The cluster autoscaler for Linode scales nodes in a LKE cluster.

Linode Kubernetes Engine

Linode Kubernetes Engine (LKE) is the managed K8s solution provided by Linode.

LKE lets users create Node Pools, i.e. groups of nodes (also called Linodes) each of the same type.

The size of a Node Pool can be configured at any moment. The user cannot select specific nodes to be deleted when downsizing a Node Pool, rather, Linode will randomly select nodes to be deleted to reach the defined size, even if a node is not healthy or has been manually deleted.

Nodes in a Node Pool are considered disposable: they can be deleted and recreated at any moment, deleting a single node or using the recycle feature, on these cases the node will be recreated by Linode after a small amount of time.

Node Pools do not support user defined tags or labels.

There is no limitation on the number of Node Pool a LKE Cluster can have, limited to the maximum number of nodes an LKE Cluster can have.

Cluster Autoscaler

A cluster autoscaler node group is composed of multiple LKE Node Pools of the same Linode type (e.g. g6-standard-1, g6-standard-2), each holding a single Linode.

At every scan interval the cluster autoscaler reviews every LKE Node Pool and if:

  • it is not among the ones to be excluded as defined in the configuration file;
  • it holds a single Linode;

then it becomes part of the node group holding LKE Node Pools of the Linode type it has, or a node group is created with this LKE Node Pool inside if there are no node groups with that Linode type at the moment.

Scaling is achieved adding LKE Node Pools to node groups, not increasing the size of a LKE Node Pool, that must stay 1. The reason behind this is that Linode does not provide a way to selectively delete a Linode from a LKE Node Pool and decrease the size of the pool with it.

This is also the reason we cannot use the standard nodes and node-group-auto-discovery cluster autoscaler flag (no labels could be used to select a specific node group), and the reason why there can be no node group of the same type.

Configuration

The cluster autoscaler automatically select every LKE Node Pool that is part of a LKE cluster, so there is no need define the node-group-auto-discovery or nodes flags, see examples/cluster-autoscaler-autodiscover.yaml for an example of a kubernetes deployment.

It is mandatory to define the cloud configuration file cloud-config. You can see an example of the cloud config file at examples/cluster-autoscaler-secret.yaml, it is an INI file with the following fields:

Key Value Mandatory Default
global/linode-token Linode API Token with Read/Write permission for Kubernetes and Linodes yes none
global/lke-cluster-id ID of the LKE cluster (numeric of the form: 12345, you can get this via linode-cli or looking at the first number of a linode in a pool, e.g. for lke15989-19461-5fec9212fad2 the lke-cluster-id is "15989") yes none
global/defaut-min-size-per-linode-type minimum size of a node group (must be > 0) no 1
global/defaut-max-size-per-linode-type maximum size of a node group no 254
global/do-not-import-pool-id Pool id (numeric of the form: 12345) that will be excluded from the pools managed by the cluster autoscaler; can be repeated no none
nodegroup "linode_type"/min-size" minimum size for a specific node group no global/defaut-min-size-per-linode-type
nodegroup "linode_type"/max-size" maximum size for a specific node group no global/defaut-min-size-per-linode-type

Log levels of interest for the Linode provider are:

  • 1 (flag: --v=1): basic logging at start;
  • 2 (flag: --v=2): logging of the node group composition at every scan;

Development

Make sure you are inside the cluster-autoscaler path of the autoscaler repository.

Create the docker image:

make container

tag the generated docker image and push it to a registry.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildLinode

BuildLinode builds the BuildLinode cloud provider.

Types

type GcfgGlobalConfig

type GcfgGlobalConfig struct {
	ClusterID       string   `gcfg:"lke-cluster-id"`
	Token           string   `gcfg:"linode-token"`
	DefaultMinSize  string   `gcfg:"defaut-min-size-per-linode-type"`
	DefaultMaxSize  string   `gcfg:"defaut-max-size-per-linode-type"`
	ExcludedPoolIDs []string `gcfg:"do-not-import-pool-id"`
}

GcfgGlobalConfig is the gcfg representation of the global section in the cloud config file for linode.

type GcfgNodeGroupConfig

type GcfgNodeGroupConfig struct {
	MinSize string `gcfg:"min-size"`
	MaxSize string `gcfg:"max-size"`
}

GcfgNodeGroupConfig is the gcfg representation of the section in the cloud config file to change defaults for a node group.

type NodeGroup

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

NodeGroup implements cloudprovider.NodeGroup interface. NodeGroup contains configuration info and functions to control a set of nodes that have the same capacity and set of labels.

Receivers assume all fields are initialized (i.e. not nil).

We cannot use an LKE pool as node group because LKE does not provide a way to delete a specific linode in a pool, but provides an API to selectively delete a LKE pool. To get around this issue, we build a NodeGroup with multiple LKE pools, each with a single linode in them.

func (*NodeGroup) AtomicIncreaseSize

func (n *NodeGroup) AtomicIncreaseSize(delta int) error

AtomicIncreaseSize is not implemented.

func (*NodeGroup) Autoprovisioned

func (n *NodeGroup) 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 (*NodeGroup) Create

func (n *NodeGroup) Create() (cloudprovider.NodeGroup, error)

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

func (*NodeGroup) Debug

func (n *NodeGroup) Debug() string

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

func (*NodeGroup) DecreaseTargetSize

func (n *NodeGroup) 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 (*NodeGroup) Delete

func (n *NodeGroup) 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 (*NodeGroup) DeleteNodes

func (n *NodeGroup) DeleteNodes(nodes []*apiv1.Node) error

DeleteNodes deletes nodes from this node group (and also increasing the size of the node group with that). 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 (*NodeGroup) Exist

func (n *NodeGroup) 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 (*NodeGroup) ForceDeleteNodes

func (n *NodeGroup) ForceDeleteNodes(nodes []*apiv1.Node) error

ForceDeleteNodes deletes nodes from the group regardless of constraints.

func (*NodeGroup) GetOptions

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

func (*NodeGroup) Id

func (n *NodeGroup) Id() string

Id returns an unique identifier of the node group.

func (*NodeGroup) IncreaseSize

func (n *NodeGroup) 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 (*NodeGroup) MaxSize

func (n *NodeGroup) MaxSize() int

MaxSize returns maximum size of the node group.

func (*NodeGroup) MinSize

func (n *NodeGroup) MinSize() int

MinSize returns minimum size of the node group.

func (*NodeGroup) Nodes

func (n *NodeGroup) 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 (*NodeGroup) TargetSize

func (n *NodeGroup) 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 (*NodeGroup) TemplateNodeInfo

func (n *NodeGroup) 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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