With the Kubernetes Cluster Autoscaler, you can automatically adjust the number of Kubernetes worker nodes in a node pool based on the needs of your workloads. For each node pool, you configure a minimum and maximum number of nodes. The Cluster Autoscaler adds or removes nodes within these limits. Autoscaling is available from Kubernetes 1.35 onwards. Older Kubernetes versions are not supported.
In our guide ‘How do I use the Kubernetes Cluster Autoscaler?’, we explain how to use the Cluster Autoscaler for your Kubernetes cluster.
Automatically added nodes are charged at the standard rate for as long as they are active. Therefore, choose the maximum number of nodes carefully.
How does the Kubernetes Autoscaler work?
The autoscaler scales up a node pool when pods cannot be scheduled due to insufficient available resources and adding an extra node from the node pool can resolve this.
The node pool is scaled down when nodes are no longer needed for an extended period and the pods on those nodes can safely run on other nodes. The number of nodes always remains between minNodeCount and maxNodeCount. The autoscaler therefore does not respond directly to measured CPU or memory usage. Kubernetes takes into account, among other things, the resource requests and scheduling requirements of pods. Therefore, configure appropriate CPU and memory requests for your workloads.
How does Horizontal Pod Autoscaler work together with Cluster Autoscaler?
Horizontal Pod Autoscaler (HPA) adjusts the number of replicas of a deployment or ReplicaSet based on the current CPU load. When the load increases, HPA creates new replicas, for which there may not be enough capacity available in the cluster. If there are insufficient resources, Cluster Autoscaler (CA) attempts to start additional nodes so that the pods created by HPA have somewhere to run. When the load decreases, HPA terminates a number of replicas. As a result, some nodes may become underutilized or completely empty, after which CA terminates these unnecessary nodes.
How can I monitor the Kubernetes Cluster Autoscaler?
Cluster Autoscaler provides metrics and livenessProbe endpoints. By default, these are available on port 8085 (configurable with the --address flag), at /metrics and /health-check, respectively. The metrics are provided in Prometheus format, and a detailed description is available here.