civo

package
v0.0.0-...-3fd892a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

Cluster Autoscaler for Civo Cloud

The cluster autoscaler for Civo Cloud scales worker nodes within any specified Civo Cloud Kubernetes cluster.

Configuration

As there is no concept of a node group within Civo Cloud's Kubernetes offering, the configuration required is quite simple. You need to set:

  • Your Civo Cloud API Key
  • The Kubernetes Cluster's ID (not the name)
  • The region of the cluster
  • The minimum and maximum number of worker nodes you want (the master is excluded)

See the cluster-autoscaler-standard.yaml example configuration, but to summarise you should set a nodes startup parameter for cluster autoscaler to specify a node group called workers e.g. --nodes=1:10:workers.

The remaining parameters can be set via environment variables (CIVO_API_KEY, CIVO_CLUSTER_ID and CIVO_REGION) as in the example YAML.

It is also possible to get these parameters through a YAML file mounted into the container (for example via a Kubernetes Secret). The path configured with a startup parameter e.g. --cloud-config=/etc/kubernetes/cloud.config. In this case the YAML keys are api_url, api_key, cluster_id and region.

Documentation

Index

Constants

View Source
const (
	// GPULabel is the label added to nodes with GPU resource.
	GPULabel = "civo.com/gpu-node"
)

Variables

View Source
var (
	// Region is the region where the cluster is located.
	Region string
)

Functions

func BuildCivo

BuildCivo builds the Civo cloud provider.

Types

type CivoNodeTemplate

type CivoNodeTemplate struct {
	// Size represents the pool size of civocloud
	Size          string            `json:"size,omitempty"`
	CPUCores      int               `json:"cpu_cores,omitempty"`
	RAMMegabytes  int               `json:"ram_mb,omitempty"`
	DiskGigabytes int               `json:"disk_gb,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
	Taints        []apiv1.Taint     `json:"taint,omitempty"`
	GpuCount      int               `json:"gpu_count,omitempty"`
	Region        string            `json:"region,omitempty"`
}

CivoNodeTemplate reference to implements TemplateNodeInfo

type Config

type Config struct {
	// ClusterID is the id associated with the cluster where Civo
	// Cluster Autoscaler is running.
	ClusterID string `json:"cluster_id" yaml:"cluster_id"`
	// ApiKey is the Civo User's API Key associated with the cluster where
	// Civo Cluster Autoscaler is running.
	ApiKey string `json:"api_key" yaml:"api_key"`
	// ApiURL is the Civo API URL
	ApiURL string `json:"api_url" yaml:"api_url"`
	// Region is the Civo region
	Region string `json:"region" yaml:"region"`
}

Config is the configuration of the Civo cloud provider

type Manager

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

Manager handles Civo communication and data caching of node groups

func (*Manager) Refresh

func (m *Manager) Refresh() error

Refresh refreshes the cache holding the nodegroups. This is called by the CA based on the `--scan-interval`. By default it's 10 seconds.

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.

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) GetOptions

GetOptions returns the options used to create this node group.

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() (*schedulerframework.NodeInfo, error)

TemplateNodeInfo returns a schedulernodeinfo.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