This page shows you how to autoscale your Standard Google Kubernetes Engine (GKE) clusters. To learn about how the cluster autoscaler works, refer to Cluster autoscaler.
With Autopilot clusters, you don't need to worry about provisioning nodes or managing node pools because node pools are automatically provisioned through node auto-provisioning, and are automatically scaled to meet the requirements of your workloads.
Using cluster autoscaler
The following sections explain how to use cluster autoscaler.
Creating a cluster with autoscaling
gcloud
To create a cluster with autoscaling, use the --enable-autoscaling
flag
and specify --min-nodes
and --max-nodes
.
The following command creates a cluster with 30 nodes. Node autoscaling is enabled and resizes the number of nodes based on cluster load. The cluster autoscaler can reduce the size of the default node pool to 15 nodes or increase the node pool to a maximum of 50 nodes.
gcloud container clusters create cluster-name --num-nodes 30 \
--enable-autoscaling --min-nodes 15 --max-nodes 50 [--zone compute-zone] | [--region compute-region]
In this command:
--num-nodes
specifies the number of nodes to create in each of the cluster's zones. The default is 3.--enable-autoscaling
indicates that autoscaling is enabled.--min-nodes
specifies the minimum number of nodes for the default node pool.--max-nodes
specifies the maximum number of nodes for the default node pool.--zone
specifies the compute zone in which the autoscaler should create new nodes.--region
specifies the [compute region] in which the autoscaler should create new nodes.
Console
To create a new cluster in which the default node pool has autoscaling enabled:
Visit the Google Kubernetes Engine menu in Cloud Console.
Click add_box Create.
Configure your cluster as desired.
From the navigation pane, under Node Pools, click default-pool.
Select the Enable autoscaling checkbox.
Change the values of the Minimum number of nodes and Maximum number of nodes fields as desired.
Click Create.
Adding a node pool with autoscaling
gcloud
The following command creates a node pool of size 3 (default), with node autoscaling based on cluster load that scales the node pool to a maximum of 5 nodes and a minimum of 1 node:
gcloud container node-pools create pool-name --cluster cluster-name \
--enable-autoscaling --min-nodes 1 --max-nodes 5 [--zone compute-zone]
In this command:
--cluster
indicates the cluster in which the node is created.--enable-autoscaling
indicates that autoscaling is enabled.--min-nodes
specifies the minimum number of nodes for the node pool.--max-nodes
specifies the maximum number of nodes for the node pool.--zone
specifies the compute zone in which the autoscaler should create new nodes.
Console
To add a node pool with autoscaling to an existing cluster:
Visit the Google Kubernetes Engine menu in Cloud Console.
In the cluster list, click the name of the cluster you want to modify.
Click add_box Add Node Pool.
Configure the node pool as desired.
Under Size, select the Enable autoscaling checkbox.
Change the values of the Minimum number of nodes and Maximum number of nodes fields as desired.
Click Create.
Enabling autoscaling for an existing node pool
gcloud
To enable autoscaling for an existing node pool, run the following command:
gcloud container clusters update cluster-name --enable-autoscaling \
--min-nodes 1 --max-nodes 10 --region compute-region || --zone compute-zone --node-pool default-pool
In this command:
--enable-autoscaling
indicates that autoscaling is enabled.--min-nodes
specifies the minimum number of nodes for the node pool.--max-nodes
specifies the maximum number of nodes for the node pool.--region
specifies the cluster's [compute region].--node-pool
specifies the desired node pool. If you have only one node pool, supplydefault-pool
to this flag.
Console
To enable autoscaling for an existing node pool:
Visit the Google Kubernetes Engine menu in Cloud Console.
In the cluster list, click the name of the cluster you want to modify.
Click the Nodes tab.
Under Node Pools, click the name of the node pool you want to modify, then click edit Edit.
Under Size, select the Enable autoscaling checkbox.
Change the values of the Minimum number of nodes and Maximum number of nodes fields as desired.
Click Save.
Disabling autoscaling for an existing node pool
gcloud
To disable autoscaling for a specific node pool, run the following command:
gcloud container clusters update cluster-name --no-enable-autoscaling \
--node-pool pool-name [--zone compute-zone --project project-id]
In this command, --no-enable-autoscaling
instructs the cluster to disable
autoscaling.
The cluster size is fixed at the cluster's current default node pool size, which can be manually updated.
Console
To disable autoscaling for a specific node pool:
Visit the Google Kubernetes Engine menu in Cloud Console.
In the cluster list, click the name of the cluster you want to modify.
Click the Nodes tab.
Under Node Pools, click the name of the node pool you want to modify, then click edit Edit.
Under Size, clear the Enable autoscaling checkbox.
Click Save.
Troubleshooting
See the following troubleshooting information for cluster autoscaler:
- You might be experiencing one of the limitations for cluster autoscaler.
- If you are having problems with downscaling your cluster, see
Pod scheduling and disruption.
You might have to add a PodDisruptionBudget for the
kube-system
Pods. For more information about manually adding a PodDisruptionBudget for thekube-system
Pods, see the cluster autoscaler FAQ.