Reviewed-by: gtema <artem.goncharov@gmail.com> Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com> Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
10 KiB
Creating an HPA Policy for Workload Auto Scaling
Horizontal Pod Autoscaling (HPA) in Kubernetes implements horizontal scaling of pods. In a CCE HPA policy, you can configure different cooldown time windows and scaling thresholds for different applications based on the Kubernetes HPA.
Prerequisites
The metrics-server add-on has been installed. This add-on collects public metrics of kubelet in Kubernetes clusters, including the CPU usage and memory usage.
Notes and Constraints
- HPA policies can be created only for clusters of v1.13 or later.
- Only one policy can be created for each workload. That is, if you have created an HPA policy, you cannot create other HPA policies for the workload. You can delete the created HPA policy and create a new one.
- For clusters earlier than v1.19.10, if an HPA policy is used to scale out a workload with EVS volumes mounted, the existing pods cannot be read or written when a new pod is scheduled to another node.
For clusters of v1.19.10 and later, if an HPA policy is used to scale out a workload with EVS volume mounted, a new pod cannot be started because EVS disks cannot be attached.
Procedure
- Log in to the CCE console. In the navigation pane, choose Auto Scaling. On the Workload Scaling tab page, click Create HPA Policy.
- In the Check Add-ons step:
- After the required add-ons have been installed, click Next: Policy configuration.
- Set policy parameters by referring to Table 1.
Table 1 HPA policy parameters Parameter
Description
Policy Name
Name of the policy to be created. Set this parameter as required.
Cluster Name
Cluster to which the workload belongs.
Namespace
Namespace to which the workload belongs.
Associated Workload
Workload with which the HPA policy is associated.
Pod Range
Minimum and maximum numbers of pods.
When a policy is triggered, the workload pods are scaled within this range.
Cooldown Period
Interval between a scale-in and a scale-out. The unit is minute. The interval cannot be shorter than 1 minute.
This parameter is available only for clusters of v1.15 and later. It is not supported in clusters of v1.13 or earlier.
This parameter indicates the interval between consecutive scaling operations. The cooldown period ensures that a scaling operation is initiated only when the previous one is completed and the system is running stably.
Rules
Policy rules can be based on system metrics.
System metrics
- Metric: You can select CPU usage or Memory usage.NOTE:
Usage = CPUs or memory used by pods/Requested CPUs or memory.
- Expected Value: Enter the expected average resource usage.
This parameter indicates the expected value of the selected metric. The number of new pods required (rounded up) = Current metric value/Expected value x Number of current pods
- Threshold: Enter the scaling thresholds.
If the metric value is greater than the scale-in threshold and less than the scale-out threshold, no scaling is triggered. This parameter is supported only in clusters of v1.15 or later.
You can click Add Rule again to add more scaling policies.
NOTE:When calculating the number of pods to be added or reduced, the HPA policy uses the maximum metrics values in the last 5 minutes.
- Metric: You can select CPU usage or Memory usage.
- After the configuration is complete, click Create. If the system displays a message indicating that the request to create workload policy *** is successfully submitted, click Back to Workload Scaling.
- On the Workload Scaling tab page, you can view the newly created HPA policy.