Achieve container scaling in seconds by using ack-autoscaling-placeholder
If your workloads must start quickly without waiting for node resources, use the ack-autoscaling-placeholder add-on. It provides a buffer for node auto scaling. When node resources are insufficient, the actual workload preempts the reserved resources and starts immediately, and node auto scaling then scales out the cluster.
Workflow
Prerequisites
-
Node auto scaling is enabled for the Container Service for Kubernetes (ACK) cluster, and an elastic node pool is configured. For more information, see Enable node autoscaling.
-
A node label is set on the elastic node pool by using the Node Labels configuration item. The label schedules workloads to the specified node pool, which makes the result easy to verify. For more information, see Create and manage node pools.
The procedure in this topic uses the
demo=yeslabel as an example.
Step 1: Deploy the ack-autoscaling-placeholder add-on and create a placeholder workload
ack-autoscaling-placeholder provides a buffer for node auto scaling, which allows cluster nodes to be over-provisioned and pre-warmed. This ensures that workloads scale out quickly without waiting for nodes to be created and added to the cluster.
This workflow commits billable resources:
-
Each placeholder replica reserves the requested CPU and memory on a running ECS instance. The reserved capacity is billed whether or not an actual workload consumes it.
-
When an actual workload preempts a placeholder, the resulting Pending placeholder triggers node auto scaling to add ECS instances, which are billed at the instance prices of the node pool.
-
The total reserved capacity equals the requests of a single replica multiplied by
replicaCount. A largerreplicaCountmultiplies the standing cost. -
To stop the cost, set
replicaCountto 0, or uninstall the ack-autoscaling-placeholder add-on.
For the pricing of the resources that this workflow uses, see ECS billing overview and Billing overview.
-
Log on to the ACK console. In the left navigation pane, click .
-
On the App Catalog tab, search for ack-autoscaling-placeholder, and then click ack-autoscaling-placeholder.
-
On the ack-autoscaling-placeholder page, click Deploy.
-
On the Parameters tab, replace the Parameter content with the following YAML sample.
ImportantSet
resources.requestsof the placeholder workload to the allocatable resources of the target node, not the total capacity of the node. Each node reserves resources for kubelet, the operating system, and kube-proxy.To check the allocatable resources, run
kubectl describe node <node-name>and view the values underAllocatable.In the creation panel, complete the configuration as prompted, and then click OK.
After the application is created, on the page, the application status is Deployed.
Step 2: Create the actual workload's PriorityClass
-
Create a file named
priorityClass.yamlwith the following YAML sample.apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: high-priority value: 1000000 # The priority value. It must be higher than the default priority of the placeholder pod in the previous step. globalDefault: false description: "High-priority class for production workloads only."Important-
A PriorityClass value must be an integer in the range of -2147483648 to 1000000000. Larger values are reserved for the built-in PriorityClasses of critical system pods.
-
The value of the PriorityClass of the actual workload must be higher than the value of the placeholder PriorityClass (
-1in this topic). Otherwise, the actual workload cannot preempt the placeholder. -
Keep the placeholder priority above the expendable pod priority threshold of node auto scaling. If it falls below the threshold, node auto scaling ignores Pending placeholder pods, no scale-out is triggered, and the pre-warmed buffer is never replenished.
-
-
Deploy the PriorityClass of the actual workload.
kubectl apply -f priorityClass.yamlExpected output:
priorityclass.scheduling.k8s.io/high-priority created
Step 3: Create the actual workload
-
Create a file named
workload.yamlwith the following YAML sample.NoteIf the
cpuormemoryrequest of the actual workload exceeds the request of the placeholder workload, the actual workload does not fit into the reserved resources, cannot start on the node where the placeholder runs, and the seconds-level startup that this topic describes does not occur. -
Deploy the actual workload.
kubectl apply -f workload.yamlExpected output:
deployment.apps/placeholder-test created
Verify the result
-
After the placeholder workload ack-place-holder is created, the pod status is Running.
-
When the actual workload is deployed, the high-priority PriorityClass allows it to preempt the resources reserved by the placeholder workload and start quickly. The pod of the placeholder workload is then evicted and stays in the Pending state because node resources are insufficient.
-
The actual workload placeholder-test is quickly deployed on the node where the placeholder workload runs.
The pod status is Running, and the number of restarts is 0, which confirms that the workload is running as expected on the target node.
-
The placeholder workload is evicted and enters the Pending state.
The pod fails to be scheduled because of
0/5 nodes are available: 1 Insufficient cpu, which indicates that no available node in the cluster meets the CPU resource requests.
-
-
Because node auto scaling is enabled for the node pool, insufficient node resources trigger a scale-out. The placeholder workload is then scheduled to the newly scaled-out node, and its status is Running.
Next steps
To achieve elastic scale-out across multiple zones in high-availability scenarios, see Enable rapid multi-zone auto scaling.