Autoscale node groups (original) (raw)

Linux Windows

If you use sole-tenant nodes for your workloads, you can automatically manage the sizes of node groups by using the node group autoscaler. You can configure autoscaling while creating a node group or after creating one.

The autoscaler can help you automatically manage the sizes of your sole-tenant node groups by:

While scaling a node group, the autoscaler considers the required capacity for the VM being scheduled, the free capacity on the nodes it is targeting, and the autoscaling policy of the node group. The required capacity is based only on the size of the VM. The free capacity is estimated based on the size of the node, the VMs already scheduled on it, and the optional CPU overcommit ratio.

The following diagram shows:

  1. The node group autoscaler scaling out by adding a new node to a node group in response to the deployment of a VM to a node group with no empty nodes.
  2. The node group autoscaler scaling by removing an empty node from a sole-tenant node group.

Node group autoscaler managing the size of the node group.

Autoscaler modes

By default, the autoscaler is not enabled on node groups. When the autoscaler is not enabled, you must manually manage the sizes of your node groups. If you enable the autoscaler on a node group, you can specify that the autoscaler both increases and decreases the size of the node group (scales out and scales in), or that it only increases the size of the group (only scales out).

Scale out and scale in

In this mode, the node group autoscaler both increases (scales out) and decreases (scales in) the size of your node groups. For this mode, you must specify a maximum size and a minimum size for the node group. The autoscaler won't scale the size of the node group above the specified maximum or below the specified minimum.

Scaling out is triggered when the scheduling for a VM fails due to lack of capacity. To resolve this issue, a new node is added to the group and the operation is tried again.

Scaling in is triggered when a node remains empty for a period of time. An empty node is a result of a VM being deleted or migrated out of the node group. If the autoscaling policy of the node group allows it, the empty node is scheduled for removal after a stabilization period. The stabilization period ensures that the node is still available if you need to use it.

Only scale out

With this mode, the autoscaler increases the size of the node group in response to requests to schedule VMs, but doesn't remove empty nodes from node groups. Google recommends this mode for monotonically increasing workloads or workloads that require physical server affinity, such as BYOL workloads, which require licenses to reside on the same physical server.

You must use this mode if your node groups are configured with the Migrate within node group maintenance policy.

Size range of a node group

When you enable the autoscaler, you set the size range of the node group by specifying a minimum and maximum value for the node group size.

If you don't specify a value for the minimum size, the autoscaler sets the minimum size to zero (0). If you do a specify value for the minimum size, it must be an integer greater than or equal to 0, and it must be less than or equal to the maximum size.

You must specify a value for the maximum size of the node group. The value must be an integer that is greater than or equal to 0 and less than or equal to 100, which is the maximum allowed size for a sole-tenant node group, and the value must be greater than or equal to the specified minimum value.

To accommodate workloads that might exceed the size maximum of 100 for a node group, create multiple node groups with matching affinity labels, for example,workload:in:my-autoscaled-node-groups. Then, schedule VMs using that affinity label, and enable autoscaling on each group to create a dynamically scaling group of node groups.

Availability

You can only use the sole-tenant node autoscaler inregions that support sole-tenant nodes.

Before you begin

Enable the node group autoscaler

Configure autoscaling on a new node group.

gcloud

The example below shows how to use the node-groups createcommand to enable the autoscaler when you are creating a node group. To add an autoscaler to an existing node group, use the node-groups updatecommand.

gcloud compute sole-tenancy node-groups create group-name
--node-template template-name
--target-size size
--maintenance-policy maintenance-policy
--zone zone
--autoscaler-mode mode
--max-nodes max-nodes
--min-nodes min-nodes

Replace the following:

REST

The following example shows how to use thenodeGroups.insertcommand to enable the autoscaler when you are creating a node group. To add an autoscaler to an existing node group, use thenodeGroups.patchcommand.

POST https://compute.googleapis.com/compute/v1/projects/project-id/zones/zone/nodeGroups?initialNodeCount=initial-node-count

{ "name": "group-name", "nodeTemplate": "template-name", "autoscalingPolicy": { "mode": "mode", "min_nodes": min-nodes, "max_nodes": max-nodes } "maintenancePolicy": maintenance-policy }

Replace the following:

Update autoscaler settings

Change the autoscaler settings on a node group by updating the autoscaler mode or by updating the minimum and maximum size of the node group.

gcloud

The following example shows how to use the node-groups updatecommand to change the mode of the autoscaler on a node group.

gcloud compute sole-tenancy node-groups update name
--autoscaler-mode mode
--max-nodes max-nodes
--min-nodes min-nodes

Replace the following:

REST

The following example shows how to use thenodeGroups.patchcommand to change the mode of an autoscaler on a node group.

PATCH https://compute.googleapis.com/compute/beta/projects/project-id/zones/group-zone/nodeGroups/group-name

{ "nodeTemplate": "template-name", "autoscalingPolicy": { "mode": "mode", "minSize": min-nodes, "maxSize": max-nodes } }

Replace the following:

Manually update the size of autoscaled node groups

When the autoscaler is enabled, node group size is managed automatically, but you can schedule or remove VMs on that node group to effectively manually update the group size.

To manually decrease the size of an autoscaled node group, delete VMs from the node until the node is empty. When the node is empty, the autoscaler removes the empty node, which decreases the size of the node group.

To manually increase the size of an autoscaled node group, set the minimum size of the group to a value greater than the current size. When the minimum size of a group is set to a value greater than the current size, the autoscaler scales out the group size to the newly specified minimum size.

When node groups are set to only scale out, the autoscaler automatically manages increases in group size and disables manual group size increases. With this setting, you can decrease the size of a group by removing VMs from a node until that node is empty, and then you can remove the empty node.

Disable the autoscaler

When you no longer need to use the autoscaler to automatically manage the sizes of your node groups, or if you need to manually manage the sizes of your node groups, disable the autoscaler.

gcloud

gcloud compute sole-tenancy node-groups update name
--autoscaler-mode OFF

Replace name with the name of the node group from which to remove the autoscaling policy.

REST

The following example shows how to use thenodeGroups.patchcommand to turn off an autoscaler on a node group.

PATCH https://compute.googleapis.com/compute/beta/projects/project-id/zones/group-zone/nodeGroups/group-name

{ "nodeTemplate": "template-name", "autoscalingPolicy": { "mode": "mode" } }

Replace the following:

View autoscaler activity

In the Google Cloud console, view the autoscaler adjusting the sizes of your node groups. The Google Cloud console shows the current size of the node group, and if the autoscaler is adjusting the size of group, you can also see the target size of the node group.

Console

  1. In the Google Cloud console, go to the Sole-tenant nodes page.
    Go to Sole-tenant nodes
  2. Click Node groups.
  3. View the number of nodes in each node group, and if Compute Engine is scaling the node group, you can also view the target number of nodes.

What's next