Enable auto scaling for a node pool

更新时间:
复制 MD 格式

If your cluster has insufficient capacity to schedule application Pods, you can use the auto scaling feature of an ACK One registered cluster to automatically expand your node resources and increase scheduling capacity. Two scaling solutions are available: node autoscaling and node instant scaling. Compared with node autoscaling, node instant scaling provides faster scaling, higher delivery efficiency, and a lower barrier to entry.

Prerequisites

Step 1: Configure RAM permissions

  1. Create a RAM user and grant it the following custom permissions. For more information, see Grant permissions to access clusters and cloud resources by using RAM.

    Custom policy

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "ess:DescribeScalingGroups",
            "ess:DescribeScalingInstances",
            "ess:DescribeScalingActivities",
            "ess:DescribeScalingConfigurations",
            "ess:DescribeScalingRules",
            "ess:DescribeScheduledTasks",
            "ess:DescribeLifecycleHooks",
            "ess:DescribeNotificationConfigurations",
            "ess:DescribeNotificationTypes",
            "ess:DescribeRegions",
            "ess:CreateScalingRule",
            "ess:ModifyScalingGroup",
            "ess:RemoveInstances",
            "ess:ExecuteScalingRule",
            "ess:ModifyScalingRule",
            "ess:DeleteScalingRule",
            "ecs:DescribeInstanceTypes",
            "ess:DetachInstances",
            "ess:CompleteLifecycleAction",
            "ess:ScaleWithAdjustment",
            "ess:DescribePatternTypes",
            "vpc:DescribeVSwitches",
            "cs:DeleteClusterNodes",
            "cs:DescribeClusterNodes",
            "cs:DescribeClusterNodePools",
            "cs:DescribeClusterNodePoolDetail",
            "cs:DescribeTaskInfo",
            "cs:ScaleClusterNodePool",
            "cs:RemoveNodePoolNodes",
            "ecs:DescribeAvailableResource",
            "ecs:DescribeInstanceTypeFamilies",
            "ecs:DescribeInstances",
            "cs:GetClusterAddonInstance",
            "cs:DescribeClusterDetail",
            "ecs:DescribeCapacityReservations",
            "ecs:DescribeElasticityAssurances",
            "ecs:DescribeImages"
          ],
          "Resource": [
            "*"
          ],
          "Effect": "Allow"
        }
      ]
    }
  2. Log on to the ACK console. In the left navigation pane, click Clusters.

  3. On the Clusters page, click the name of your cluster. In the left navigation pane, click Configurations > Secrets.

  4. On the Secrets page, click Create from YAML and use the following YAML to create a Secret named alibaba-addon-secret.

    Note

    The component uses the AccessKey ID and AccessKey secret in this Secret to access cloud services. If the alibaba-addon-secret Secret already exists, you can skip this step.

    apiVersion: v1
    kind: Secret
    metadata:
      name: alibaba-addon-secret
      namespace: kube-system
    type: Opaque
    stringData:
      access-key-id: <AccessKey ID of the RAM user>
      access-key-secret: <AccessKey secret of the RAM user>

Step 2: Configure node scaling

Node autoscaling

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Nodes > Node Pools.

  3. On the Node Pools page, click Enable next to Node Scaling.

    1.jpg

  4. If you are using node autoscaling for the first time, follow the on-screen instructions to activate the Auto Scaling service.

  5. In the Node Scaling Configuration panel, set Node Scaling Plan to Auto Scaling, configure the parameters, and then click OK.

    You can switch the node scaling method at any time. To do so, change the method to node instant scaling, read the on-screen instructions carefully, and complete the operation as instructed.

    Parameter

    Description

    Node Pool Scale-out Policy

    • Random Policy: If multiple node pools can be scaled out, one is selected at random.

    • Default Policy: If multiple node pools can be scaled out, the one that wastes the fewest resources is selected.

    • Priority-based Policy: If multiple node pools can be scaled out, the one with the highest priority is selected.

      The priority of a node pool is defined by the Node Pool Scale-out Priority parameter.

    Node Pool Scale-out Priority

    Sets the scale-out priority for node pools. This parameter is effective only when Node Pool Scale-out Policy is set to Priority-based Policy.

    The value can be an integer from 1 to 100. A larger value indicates a higher priority.

    Click Add next to the parameter, select a node pool with auto scaling enabled, and set its priority.

    If no auto-scaled node pools are available, you can skip this parameter for now and configure it after you complete Step 2: Configure a node pool for auto scaling.

    Scaling Sensitivity

    The interval at which the system checks whether to perform a scaling activity. The default value is 60s.

    During auto scaling, the scaling component automatically triggers scale-out events based on scheduling needs.

    Important
    • ECS nodes: The scaling component scales in a node only if the conditions for Scale-in Threshold, Scale-in Trigger Delay, and Cooldown Period are all met.

    • GPU nodes: The scaling component scales in a GPU node only if the conditions for GPU Scale-in Threshold, Scale-in Trigger Delay, and Cooldown Period are all met.

    Allow Scale-in

    Specifies whether to allow node scale-in. If disabled, scale-in configurations are ignored. Use this setting with caution.

    Scale-in Threshold

    The ratio of total resource requests to the total resource capacity of a single node in a node pool with node auto scaling enabled.

    A node is eligible for scale-in only when both its CPU and memory resource utilization are lower than the Scale-in Threshold.

    GPU Scale-in Threshold

    The scale-in threshold for GPU instances.

    A GPU node can be scaled in only if its CPU, memory, and GPU resource utilization are all lower than the GPU Scale-in Threshold.

    Scale-in Trigger Delay

    The delay between detecting a scale-in need and executing the scale-in. Unit: minutes. Default: 10 minutes.

    Important

    The scaling component may perform a node scale-in only after the condition for Scale-in Threshold is met and the duration specified for Scale-in Trigger Delay has passed.

    Cooldown Period

    The period after a scale-out during which the component prevents scale-in operations.

    During the cooldown period, the scaling component will not scale in nodes but will continue to check if nodes meet the scale-in conditions. After the cooldown period ends, if a node meets both the scale-in threshold and the scale-in delay conditions, the scaling component will proceed with the scale-in. For example, if the cooldown is 10 minutes and the scale-in delay is 5 minutes, the component will not scale in nodes for 10 minutes after a scale-out. However, it will evaluate nodes for scale-in eligibility during this time. Once the 10-minute cooldown ends, if a node has met the threshold and has been eligible for more than 5 minutes, it will be scaled in.

    View advanced settings

    Parameter

    Description

    Pod Termination Timeout

    The maximum amount of time to wait for pods on a node to terminate during a scale-in. Unit: seconds.

    If a pod is not evicted before the timeout, its node is not released during that scale-in.

    Minimum Pod Replicas

    Sets a scale-in protection threshold for applications managed by a ReplicationController or ReplicaSet. If the current number of replicas for an application is less than this value, nodes that run its pods are not scaled in.

    This parameter affects only pods managed by a ReplicationController or ReplicaSet. It does not apply to pods managed by other controllers, such as StatefulSet or DaemonSet.

    Enable DaemonSet Pod Eviction

    If you enable this option, DaemonSet pods on a node are evicted when the node is scaled in.

    Skip nodes with pods in the kube-system namespace

    If you enable this option, the auto scaler ignores nodes that run pods in the kube-system namespace during scale-in operations. This ensures that these nodes are not affected by scaling.

    Note

    This feature does not apply to DaemonSet pods or mirror pods.

Node instant scaling

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Nodes > Node Pools.

  3. On the Node Pools page, click Enable next to Node Scaling.

    1.jpg

  4. If this is the first time you are using auto scaling, follow the on-screen instructions to activate the Auto Scaling service.

  5. On the Node Scaling Configuration page, set Node Scaling Plan to Instant Scaling, configure the scaling parameters, and then click OK.

    During auto scaling, the scaling component automatically triggers a scale-out based on scheduling conditions.

    You can switch the Node Scaling Solution after it is selected. To switch, you can change the solution to node auto scaling here. Read the prompts on the page and follow the instructions. This feature is available only to beta users. To use this feature, submit a ticket.

    Parameter

    Description

    Scale-in Threshold

    The ratio of total resource requests to the total resource capacity of a single node in a node pool with node auto scaling enabled.

    A node is eligible for scale-in only when both its CPU and memory resource utilization are lower than the Scale-in Threshold.

    GPU Scale-in Threshold

    The scale-in threshold for GPU instances.

    A GPU node can be scaled in only if its CPU, memory, and GPU resource utilization are all lower than the GPU Scale-in Threshold.

    Scale-in Trigger Delay

    The delay between detecting a scale-in need and executing the scale-in. Unit: minutes. Default: 10 minutes.

    Important

    The scaling component may perform a node scale-in only after the condition for Scale-in Threshold is met and the duration specified for Scale-in Trigger Delay has passed.

    Advanced configurations

    Parameter

    Description

    Pod Termination Timeout

    The maximum amount of time to wait for pods on a node to terminate during a scale-in. Unit: seconds.

    If a pod is not evicted before the timeout, its node is not released during that scale-in.

    Minimum Pod Replicas

    Sets a scale-in protection threshold for applications managed by a ReplicationController or ReplicaSet. If the current number of replicas for an application is less than this value, nodes that run its pods are not scaled in.

    This parameter affects only pods managed by a ReplicationController or ReplicaSet. It does not apply to pods managed by other controllers, such as StatefulSet or DaemonSet.

    Enable DaemonSet Pod Eviction

    If you enable this option, DaemonSet pods on a node are evicted when the node is scaled in.

    Skip nodes with pods in the kube-system namespace

    If you enable this option, the auto scaler ignores nodes that run pods in the kube-system namespace during scale-in operations. This ensures that these nodes are not affected by scaling.

    Note

    This feature does not apply to DaemonSet pods or mirror pods.

Step 3: Configure a node pool

You can enable auto scaling for an existing node pool by setting its Scaling Mode to Auto, or create a new node pool with this feature enabled. For more information, see Create and manage a node pool. The following table describes the key parameters.

Parameter

Description

Scaling Mode

  • Manual: ACK adjusts the node count in the node pool based on the configured Expected Number of Nodes, maintaining the node count at the Expected Number of Nodes. For details, see Manually scale node pools.

  • Auto: When cluster capacity planning cannot meet application pod scheduling demands, ACK automatically scales node resources based on configured minimum and maximum instance counts. Clusters running Kubernetes 1.24 or later default to node instant scaling; clusters running earlier versions default to node autoscaling. For details, see Node scaling.

Instances

The Min. Instances and Max. Instances that the node pool can be scaled to. This does not include existing instances.

Note
  • If Min. Instances is greater than 0, the specified number of ECS instances are automatically created after the scaling group takes effect.

  • We recommend that you set Max. Instances to a value no less than the current number of nodes in the node pool. Otherwise, a scale-in is immediately triggered after auto scaling takes effect.

Instance-related parameters

When scaling out, nodes are allocated from the configured ECS instance families. To improve scale-out success rates, select multiple instance types across multiple zones to avoid unavailability or insufficient inventory. The specific instance type used for scaling is determined by the configured Scaling Policy.

To ensure business stability and accurate resource scheduling, do not mix GPU and non-GPU instance types in the same node pool.

Configure instance types for scaling in one of two ways:

  • Specific types: Specify exact instance types based on vCPU, memory, family, architecture, and other dimensions.

  • Generalized configuration: Select instance types to use or exclude based on attributes (vCPU, memory, etc.) to further improve scale-out success rates. For details, see Configure node pools using specified instance attributes.

Refer to the console's elasticity strength recommendations for configuration, or view node pool elasticity strength after creation.

For ACK-unsupported instance types and node configuration recommendations, see ECS instance type configuration recommendations.

Cloud resource and billing information: imageECS instance, imageGPU instance

Operating System

When auto scaling is enabled, you can select Alibaba Cloud Linux, Windows, or Windows Core images.

If you select a Windows or Windows Core image, the system automatically applies the { effect: 'NoSchedule', key: 'os', value: 'windows' } taint.

Node Labels

Labels you add to the node pool are automatically applied to nodes created during a scale-out.

Important

Auto scaling can recognize node labels and taints only after they are mapped to node pool tags. A node pool has a limit on the number of tags it can have. Therefore, the total number of ECS tags, taints, and node labels for a node pool with auto scaling enabled must not exceed 12.

scaling policy

Configure how the node pool selects instances during scaling.

  • Priority-based Policy: Scales based on the vSwitch priority configured in the cluster (vSwitch order from top to bottom indicates decreasing priority). If instances cannot be created in the higher-priority zone, the next priority vSwitch is used automatically.

  • Cost Optimization: Scales from lowest to highest vCPU unit price.

    When the node pool uses Preemptible Instance, spot instances are prioritized. You can configure the Percentage of pay-as-you-go instances (%) to automatically supplement with pay-as-you-go instances when spot instances cannot be created due to inventory or other reasons.

  • Distribution Balancing: Distributes ECS instances evenly across multiple zones, but only in multi-zone scenarios. If zone distribution becomes unbalanced due to inventory shortages, you can rebalance.

Use Pay-as-you-go Instances When Spot Instances Are Insufficient

Requires selecting spot instances as the billing method.

When enabled, if sufficient spot instances cannot be created due to price or inventory reasons, ACK automatically attempts to create pay-as-you-go instances as a supplement.

Cloud resource and billing information: imageECS instance

Enable Supplemental Spot Instance

Requires selecting spot instances as the billing method.

When enabled, upon receiving a system notification that a spot instance will be reclaimed (5 minutes before reclamation), ACK attempts to scale out new instances for compensation.

  • Compensation successful: ACK drains the old node and removes it from the cluster.

  • Compensation failed: ACK does not drain the old node, and the instance is reclaimed after 5 minutes. When inventory is restored or price conditions are met, ACK automatically purchases instances to maintain the desired node count. For details, see Spot instance node pool best practices.

Active release of spot instances may cause business disruptions. To improve compensation success rates, we recommend also enabling Use Pay-as-you-go Instances When Spot Instances Are Insufficient.

Cloud resource and billing information: imageECS instance

Scaling Mode

Requires enabling Auto Scaling for the node pool and setting Scaling Mode to Auto.
  • Standard: Scales by creating and releasing ECS instances.

  • Swift: Scales by creating, stopping, and restarting ECS instances. When scaling is needed again, stopped instances are restarted directly, improving scaling speed.

    Stopped ECS instances do not incur compute resource fees, only storage fees (except for instance families with local storage capabilities, such as big data and local SSD types). For billing details and considerations about ECS instance stop modes, see Economical mode.

Taints

After you add a taint, the scheduler will not place new Pods on that node.

Step 4: (Optional) Verify the results

After you complete these steps, the node autoscaling feature is enabled. The node pool status indicates that auto scaling is active, and the cluster-autoscaler is automatically installed in your cluster.

Auto scaling for the node pool

On the Node Pools page, the list shows the node pools that have auto scaling enabled.

Installed cluster-autoscaler

  1. In the left navigation pane of the cluster management page, choose Workload > Deployments.

  2. In the kube-system namespace, find the cluster-autoscaler.