This topic describes how to enable auto scaling for a hybrid cluster.
Prerequisites
When you configure auto scaling, the cluster-autoscaler component is automatically
deployed as a Deployment in the hybrid cluster. Cloud computing nodes that are added
to a cluster during a scale-out event may later be removed in a scale-in event. If
you install system components that run as Deployments on these nodes, the system components
may not be able to provide stable services. Therefore, you must make sure that these
components are not scheduled to automatically added cloud computing nodes or on-premises
nodes. The following conditions must be met:
Step 1: Configure auto scaling
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, perform the following steps to go to the Configure Auto Scaling page.
You can go to the Configure Auto Scaling page in the following ways:
- Method 1: Find the cluster that you want to manage and choose in the Actions column.
- Method 2:
- Find the cluster that you want to manage and click Details in the Actions column.
- In the left-side navigation pane, choose .
- In the upper-right corner of the Node Pools page, click Configure Auto Scaling.
- On the Configure Auto Scaling page, set the parameters and then click submit.
- Configure the cluster-autoscaler component.
After you configure auto scaling, a Deployment of the cluster-autoscaler component
is automatically created in the cluster.
- Run the following command to query the Deployment:
kubectl -n kube-system get deploy |grep cluster-autoscaler
The following output is returned:
cluster-autoscaler 1/1 1 1 5s
- Configure the RAM policy that enables the cluster-autoscaler component to access other
resource. The sample code is as follows:
{
"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",
"vpc:DescribeVSwitches"
],
"Resource": [
"*"
],
"Effect": "Allow"
}
]
}
- Run the following commands to specify the AccessKey pair that is used to grant the
RAM policy:
export ACCESS_KEY_ID=<ACCESS KEY ID>
export ACCESS_KEY_SECRET=<ACCESS KEY SECRET>
- Run the following command to create a Secret named alibaba-addon-secret:
kubectl -n kube-system create secret generic alibaba-addon-secret --from-literal='access-key-id=${ACCESS_KEY_ID}' --from-literal='access-key-secret=${ACCESS_KEY_SECRET}'
Step 2: Create a node pool for auto scaling
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, perform the following steps to go to the Configure Auto Scaling page.
You can go to the Configure Auto Scaling page in the following ways:
- Method 1: Find the cluster that you want to manage and choose in the Actions column.
- Method 2:
- Find the cluster that you want to manage and click Details in the Actions column.
- In the left-side navigation pane, choose .
- In the upper-right corner of the Node Pools page, click Configure Auto Scaling.
- On the Configure Auto Scaling page, click Create Node Pool.
- In the Create Node Pool dialog box, set the parameters for the node pool.
The parameters are described in the following table.
Parameter |
Description |
Quantity |
Set the initial number of nodes in the node pool. If you do not want to create nodes
in the node pool, set this parameter to 0.
|
Operating System |
Select the operating system for the nodes. Valid values: CentOS and Alibaba Cloud
Linux 2.1903.
|
Node Label |
You can add labels to nodes in the node pool. For example, workload=auto .
|
ECS Label |
You can add labels to the ECS instances in the node pool. |
Taints |
You can add taints to nodes in the node pool. |
Security Group |
Select the security group to which the nodes belong. |
For more information about the parameters, see Create a dedicated Kubernetes cluster.
- Click OK.
Expected result
Run the following command to verify whether nodes that have the specified
label, such as
workload=auto
, are added to the cluster:
kubectl run nginx --image nginx -l workload=auto