This page provides an overview of Cluster Autoscaler and how to use it with Google Container Engine.
Cluster Autoscaler enables users to automatically resize clusters so that all scheduled pods have a place to run. If there are no resources in the cluster to schedule a recently created pod, a new node is added. On the other hand, if some node is underutilized and all pods running on it can be easily moved elsewhere then the node is deleted. This feature allows users to pay only for resources that are actually needed and get new resources when the demand increases.
When to use Cluster Autoscaler
The feature should be used when the cluster administrator wants the cluster to be automatically resized and can tolerate some disruptions that may happen when a node is deleted (for example, a replicated pod may not be running until it is scheduled again), unless part of a replica set of two or larger.
How Cluster Autoscaler works
Cluster Autoscaler periodically checks whether there are any pods waiting for a node with free resources and are not being scheduled. If such pods exist, and the Cluster Autoscaler determines that resizing a node pool would allow the pod to be scheduled, then a node pool resize is executed.
Cluster Autoscaler also monitors the usage of all nodes. If a node is not needed for an extended period of time and all of its pods can be easily scheduled elsewhere then the node is deleted.
Cluster Autoscaler is configured per node pool. The user specifies the minimal and maximal size of each node pool and Cluster Autoscaler makes rescaling decisions within these boundaries. If the current cluster size is greater than the specified maximum, then Cluster Autoscaler waits until a new node is needed or a node can be safely deleted.
You can enable autoscaling by using the
gcloud command-line tool. Here is an
gcloud alpha container clusters update mycluster --enable-autoscaling --min-nodes=1 --max-nodes=10 --zone=us-central1-f --node-pool=default-pool
There are certain assumptions that Cluster Autoscaler makes when executing node pool resizing that are good to be aware of, and certain conditions in which using Cluster Autoscaler is not supported.
- Cluster Autoscaler assumes that all replicated pods can be restarted on some other node, possibly causing a brief disruption. If this is not the case then Cluster Autoscaler should not be used (yet).
- Cluster Autoscaler assumes that the nodes are not modified by the user and all nodes in a single node pool have the same set of labels.
- Cluster Autoscaler should not be used (yet) with large clusters (>100-150 nodes with lots of pods).
- Cluster Autoscaler works best if there is only a single node pool in the cluster. It works with multiple node pools but it does not (yet) take machine cost into account so it may pick the more expensive node pool to resize.