Autoscaling a Cluster

This page shows you how to autoscale your Google Kubernetes Engine clusters. To learn about how the cluster autoscaler works, refer to Cluster Autoscaler.

Using cluster autoscaler

The following sections explain how to use cluster autoscaler.

Creating a cluster with autoscaling

gcloud

The following command creates a cluster of size 30, with node autoscaling based on cluster load that scales the default node pool to a maximum of 50 nodes and a minimum of 15 nodes:

gcloud container clusters create [CLUSTER_NAME] --num-nodes 30 \
    --enable-autoscaling --min-nodes 15 --max-nodes 50 [--zone [COMPUTE_ZONE]]

In this command:

  • --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.

Console

To create a new cluster in which the default node pool has autoscaling enabled, perform the following steps:

  1. Visit the Google Kubernetes Engine menu in GCP Console.

    Visit the Google Kubernetes Engine menu

  2. Click Create cluster.

  3. Configure the cluster as desired, then click Advanced edit for the default node pool.
  4. In the Size section, select Enable autoscaling.
  5. Change the values of the Minimum size and Maximum size fields as desired.
  6. Click Save to exit the Advanced edit overlay.
  7. 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, perform the following steps:

  1. Visit the Google Kubernetes Engine menu in GCP Console.

    Visit the Google Kubernetes Engine menu

  2. Click the desired cluster, then click Edit.

  3. From the Node Pools menu at the bottom of the page, click Add node pool.
  4. Configure the node pool as desired, Then, from the Autoscaling drop-down menu, select On.
  5. Click Save.

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 --zone [COMPUTE_ZONE] --node-pool default-pool

In this command:

  • --enable-autoscaling indicates that autoscaling is enabled.
  • --node-pool specifies the node pool for which 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 cluster's [compute zone].
  • --node-pool specifies the desired node pool. If you have only one node pool, supply default-pool to this flag.

Console

To enable autoscaling for a specific node pool, perform the following steps:

  1. Visit the Google Kubernetes Engine menu in GCP Console.

    Visit the Google Kubernetes Engine menu

  2. Click the desired cluster, then click Edit.

  3. From the Node Pools menu at the bottom of the page, select the desired node pool by clicking its title to expand it. The default node pool is expanded by default.
  4. From the Autoscaling drop-down menu, click On.
  5. Change the values of the Minimum size and Maximum size fields as desired.
  6. 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, perform the following steps:

  1. Visit the Google Kubernetes Engine menu in GCP Console.

    Visit the Google Kubernetes Engine menu

  2. To add labels to a single cluster, click its Edit button, which looks like a pencil.

  3. From the Node Pools menu at the bottom of the page, select the desired node pool by clicking its title to expand it. The default node pool is expanded by default.
  4. From the Autoscaling drop-down menu, click Off.
  5. Click Save.

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Kubernetes Engine