Scalling of K8s resources

Scaling your computing resources is one of the most important jobs and tedious if you do it manually. So Autoscaling comes into the picture.

Resources can be scaled in 2 primary ways: horizontally and vertically. If you add or reduce more resources in parallel along with your current one, that is called horizontal scaling, and if you just increase or decrease the capacity of your current running resource, that is vertical scaling.

Now in a K8s environment, this can be done either at the workload level (like a pod or deployment) or at the node level. So we can work with the Pods or with the Nodes.

In the case of horizontal autoscaling, we have

  1. Horizontal Pod Autoscaler (HPA) for pods.

  2. Cluster Autoscaler for the Node.

In the case of vertical autoscaling, we have

  1. Vertical Pod Autoscaler (VPA) for pods.

  2. Node AutoProvisioning.

One event-based autoscaler is also there, named KEDA.

In K8s, HPA comes by default with the cluster; VPA is a separate project, so you have to install it. Cluster Autoscaler and Node AutoProvisioning are hardware-level things because you have to create a new node, so first you have to attach it, and then you will be able to use this feature.

HPA command


kubectl autoscale deploy DEPLOYMENT-NAME --cpu-percent=60 --min=10 --max=100

VPA installation in managed clusters


kubectl apply -f https://github.com/kubernetes/autoscaler/releases/latest/download/vertical-pod-autoscaler.yaml

VPA installation from GitHub Project


git clone https://github.com/kubernetes/autoscaler.git

cd autoscaler/vertical-pod-autoscaler/

./hack/vpa-up.sh