As application access requests fluctuate, the preset number of pods often fails to meet the requirements for efficient, elastic resource utilization. For example, if the number of pods is insufficient during peak hours, the response delay may increase and user experience may deteriorate. If the number of pods is excessive during off-peak hours, resources go wasted.
Kubernetes provides the HPA policy to horizontally scale pods. The HPA policy monitors application loads, such as the CPU usage and memory usage, and automatically increases or decreases the number of pods to adapt to the current workload. This ensures stable application performance and efficient resource utilization.
For clusters of v1.19.10 and later, if an HPA policy is used to scale out a workload with EVS volumes mounted, a new pod cannot be started because EVS disks cannot be attached.
This section describes only HPA policies. To enable CronHPA, see Creating a Scheduled CronHPA Policy.
Parameter |
Description |
|---|---|
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 supported only in clusters of v1.15 to v1.23. 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. |
Scaling Behavior |
This parameter is supported only in clusters of v1.25 or later.
|
System Policy |
When calculating the number of pods to add or remove, HPA determines the target number of pods based on the current metric value, desired value, and the current number of pods. The current number of pods is the maximum number of pods over the last 5 minutes. The formula is as follows: Desired number of pods = Rounded up value of [Current number of pods x (Current metric value/Desired value)]
|
Custom Policy (supported only in clusters of v1.15 or later) |
NOTE:
Before creating a custom policy, install an add-on that supports custom metric collection (for example, Prometheus) in the cluster. Ensure that the add-on can collect and report the custom metrics of the workloads. For details, see Monitoring Custom Metrics Using Cloud Native Cluster Monitoring.
|