Kubernetes cluster autoscaling using Kubeadm Kubernetes cluster autoscaling using Kubeadm kubernetes kubernetes

Kubernetes cluster autoscaling using Kubeadm


K8s cluster can be scaled with the help of Cluster Autoscaler(CA) cluster autoscaler github page, find info on AWS CA there.

It is not scaling the cluster based on “total memory utilization” but based on “pending pods” in the cluster due to not enough available cluster resources to meet their CPU and Memory requests. Basically, Cluster Autoscaler(CA) checks for pending(unschedulable) pods every 10 seconds and if it finds any, it will request AWS Autoscaling Group(ASG) API to increase the number of instances in ASG. When a node to ASG is added, it then joins the cluster and becomes ready to serve pods. After that K8s Scheduler allocates “pending pods” to a new node.

Scale-down is done by CA checking every 10 seconds which nodes are unneeded and the node is considered for removal if: the sum of CPU and Memory Requests of all pods is smaller than 50% of node’s capacity, pods can be moved to other nodes and no scale-down disabled annotation. 

If K8s cluster on AWS is administered with Kubeadm, all the above holds true. So in a nutshell(intricate details omitted, refer to the doc on CA):

Create Autoscaling Group(ASG) aws ASG doc.

Add tags to ASG like k8s.io/cluster-autoscaler/enable(mandatory), k8s.io/cluster-autoscaler/cluster_name(optional).

Launch “CA” in a cluster following the offical doc.