Autoscaling Microservices in Kubernetes: Horizontal Autoscaling
Cluster Autoscaler
The Cluster Autoscaler (CA) is a tool that automatically adjusts the size of a Kubernetes cluster in response to the following conditions:
- Pods fail to run in the cluster due to insufficient resources, and
- Nodes in the cluster remain underutilized for an extended period of time, and their Pods can be placed on other existing nodes.
The Cluster Autoscaler is a separate component and has no relation to the HPA, but it could be considered a horizontal autoscaler for the cluster itself. Also, it is not part of the Kubernetes control plane; it is deployed as a Deployment in the kube-system namespace.
Most cloud providers have their own implementation of the Cluster Autoscaler. In most cases, you should use the one provided by your cloud provider since it is optimized for the cloud provider's infrastructure, it is easier to install (usually from the CLI or the web interface), and it is easier to configure.
For example, if we're using DigitalOcean, we can use the web interface to install and configure the Cluster Autoscaler.
Adjust node count using the DigitalOcean web console
Or use the CLI:
doctl kubernetes cluster node-pool update mycluster mypool \
--auto-scale \
--min-nodes 1 \
--max-nodes 10
where:
myclusteris the name of the clustermypoolis the name of the node poolauto-scaleenables the Cluster Autoscalermin-nodesis the minimum number of nodes that the Cluster Autoscaler will scale down tomax-nodesis the maximum number of nodes that the Cluster Autoscaler will scale up to
You can disable it using:
doctl kubernetes cluster node-pool update mycluster mypool \
--auto-scale=false
These are some official links to the Cluster Autoscaler documentation and implementations for different cloud providers:
Cloud-Native Microservices With Kubernetes - 2nd Edition
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in KubernetesEnroll now to unlock all content and receive all future updates for free.

