Managing HPA Policies
In Kubernetes, a HorizontalPodAutoscaler is a built-in component that provides horizontal pod autoscaling (HPA). It supports the application-level cooldown time window and scaling threshold functions based on the Kubernetes HPA.
Restrictions
- You can set the HPA policy only for the components created and deployed using the following methods:
- Workload Type of the component is Stateless.
- The component status is Running or Not ready. For details about how to check the component status, see Viewing Component Details.
- The version of the CCE cluster bound to the component must be 1.15 or later.
Creating an HPA Policy
- Log in to ServiceStage.
- Use either of the following methods to go to the Scaling page.
- On the Application Management page, click the application to which the component belongs, click the target component in Component List, and choose Scaling in the left navigation pane.
- On the Component Management page, click the target component and choose Scaling in the left navigation pane.
- If the component is created by Creating a Component by Importing a CCE Workload and is not enabled:
- In the displayed dialog box, click OK.
- On the Enable Component page, click Enable and wait until the component is restarted.
- Click
next to Auto Scaling to enable auto scaling policy configuration. The Create AS Policy page is displayed.
- Click Install one to install metrics-server by referring to Installing Metrics Server.
Wait until the plug-in is installed. If Status is Running, the plug-in is installed successfully.
- Return to the Create AS Policy page.
- Click Refresh to refresh the page.
- Configure the HPA policy.
- Policy Name
Enter a policy name. After the policy is created, its name cannot be changed.
Enter 4 to 63 characters. Start with a lowercase letter and end with a lowercase letter or digit. Only use lowercase letters, digits, and hyphens (-).
- Cooldown Period
This parameter is supported only in clusters of v1.15 to v1.23.
Enter a scale-out/scale-in cooldown period, in minute. The minimum period is 1 minute.
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.
- Instances
Enter the minimum and maximum numbers of pods. The minimum number is an integer ranging from 1 to 299. The maximum number is an integer ranging from 1 to 1500 and must be greater than the minimum number.
After the policy is triggered, the workload pods are scaled within this range.
- Scaling Behavior
This parameter is supported only in clusters of v1.25 or later.
- Default: scales workloads using the Kubernetes default behavior.
- Custom: scales workloads using custom policies such as stabilization window, steps, and priorities. For parameters that are not set, the default values recommended by the Kubernetes community are used.
- Disable scale-out/scale-in: Select whether to disable scale-out or scale-in.
- Stabilization Window: a period during which CCE continuously checks whether the metrics used for scaling keep fluctuating. CCE triggers scaling if the desired state is not maintained for the entire window. This window restricts the unwanted flapping of pod count due to metric changes.
- Step: scaling step. You can set the number or percentage of pods to be scaled in or out within a specified period. If there are multiple policies, you can select the policy that maximizes or minimizes the number of pods.
- Triggering Condition
You can configure trigger condition on the UI or by editing the YAML file.
Before setting trigger conditions of CPU usage or Memory usage, you need to set the CPU quota (CPU) or memory quota (Memory) for the component.
To modify the quotas, click Increase quota, set component resource parameters, and upgrade the component. You can customize CPU and Memory to set their quota, and set the maximum/minimum number of CPU cores and memory size (GiB) that can be used by components. In this way, you can set the number of resources required by each component instance. For details about how to upgrade a component, see Upgrading a Component in Single-batch Release Mode.
- UI
- Metric: Select CPU usage or Memory usage.
Usage = Average resource usage of all pods in a workload/Requested resources
- Desired Value: desired average resource usage. Number of pods to be scaled (rounded up) = (Current metric value/Desired value) x Number of current pods
When calculating the number of pods to be added or reduced, the HPA policy uses the maximum number of pods in the last 5 minutes.
- Threshold: Scaling is not triggered when the desired value is within the range. The desired value must be within the threshold range. 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.
- Metric: Select CPU usage or Memory usage.
- YAML
To configure custom metric parameters by using YAML, ensure that the prometheus add-on has been installed for the CCE cluster.
Install the prometheus add-on for the CCE cluster. For details, see prometheus.metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 50 - type: Resource resource: name: memory target: type: Utilization averageUtilization: 50 - type: Pods pods: metric: name: packets-per-second target: type: AverageValue averageValue: 1k - type: Object object: metric: name: requests-per-second describedObject: apiVersion: networking.k8s.io/v1beta1 kind: Ingress name: main-route target: type: Value value: 10k
As shown in the preceding example, in addition to using the CPU and memory usage as metrics, you can use the YAML format to customize metric parameters and support more metrics such as pods, object, and external.
- UI
- Policy Name
- Click Create Now.
Modifying an HPA Policy
- Log in to ServiceStage.
- Use either of the following methods to go to the Scaling page.
- On the Application Management page, click the application to which the component belongs, click the target component in Component List, and choose Scaling in the left navigation pane.
- On the Component Management page, click the target component and choose Scaling in the left navigation pane.
- On the Scaling page, choose Policy, click Edit, and reconfigure parameters.
- Cooldown Period
This parameter is supported only in clusters of v1.15 to v1.23.
Enter a scale-out/scale-in cooldown period, in minute. The minimum period is 1 minute.
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.
- Instances
Enter the minimum and maximum numbers of pods. The minimum number is an integer ranging from 1 to 299. The maximum number is an integer ranging from 1 to 1500 and must be greater than the minimum number.
After the policy is triggered, the workload pods are scaled within this range.
- Scaling Behavior
This parameter is supported only in clusters of v1.25 or later.
- Default: scales workloads using the Kubernetes default behavior.
- Custom: scales workloads using custom policies such as stabilization window, steps, and priorities. For parameters that are not set, the default values recommended by the Kubernetes community are used.
- Disable scale-out/scale-in: Select whether to disable scale-out or scale-in.
- Stabilization Window: a period during which CCE continuously checks whether the metrics used for scaling keep fluctuating. CCE triggers scaling if the desired state is not maintained for the entire window. This window restricts the unwanted flapping of pod count due to metric changes.
- Step: scaling step. You can set the number or percentage of pods to be scaled in or out within a specified period. If there are multiple policies, you can select the policy that maximizes or minimizes the number of pods.
- Triggering Condition
You can configure trigger condition on the UI or by editing the YAML file.
Before setting trigger conditions of CPU usage or Memory usage, you need to set the CPU quota (CPU) or memory quota (Memory) for the component.
To modify the quotas, click Increase quota, set component resource parameters, and upgrade the component. You can customize CPU and Memory to set their quota, and set the maximum/minimum number of CPU cores and memory size (GiB) that can be used by components. In this way, you can set the number of resources required by each component instance. For details about how to upgrade a component, see Upgrading a Component in Single-batch Release Mode.
- UI
- Metric: Select CPU usage or Memory usage.
Usage = Average resource usage of all pods in a workload/Requested resources
- Desired Value: desired average resource usage. Number of pods to be scaled (rounded up) = (Current metric value/Desired value) x Number of current pods
When calculating the number of pods to be added or reduced, the HPA policy uses the maximum number of pods in the last 5 minutes.
- Threshold: Scaling is not triggered when the desired value is within the range. The desired value must be within the threshold range. 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.
- Metric: Select CPU usage or Memory usage.
- YAML
To configure custom metric parameters by using YAML, ensure that the prometheus add-on has been installed for the CCE cluster.
Install the prometheus add-on for the CCE cluster. For details, see prometheus.metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 50 - type: Resource resource: name: memory target: type: Utilization averageUtilization: 50 - type: Pods pods: metric: name: packets-per-second target: type: AverageValue averageValue: 1k - type: Object object: metric: name: requests-per-second describedObject: apiVersion: networking.k8s.io/v1beta1 kind: Ingress name: main-route target: type: Value value: 10k
As shown in the preceding example, in addition to using the CPU and memory usage as metrics, you can use the YAML format to customize metric parameters and support more metrics such as pods, object, and external.
- UI
- Cooldown Period
- Click OK.
Viewing the Running Status of an HPA Policy
- Log in to ServiceStage.
- Use either of the following methods to go to the Scaling page.
- On the Application Management page, click the application to which the component belongs, click the target component in Component List, and choose Scaling in the left navigation pane.
- On the Component Management page, click the target component and choose Scaling in the left navigation pane.
- On the Scaling page:
- Click the Status tab to view the policy running status.
- Click the Event tab to view events that occur during policy running.
Disabling an HPA Policy
After the HPA policy is disabled, all data will be cleared. Exercise caution when performing this operation.
- Log in to ServiceStage.
- Use either of the following methods to go to the Scaling page.
- On the Application Management page, click the application to which the component belongs, click the target component in Component List, and choose Scaling in the left navigation pane.
- On the Component Management page, click the target component and choose Scaling in the left navigation pane.
- On the Scaling page, click
on the right of Auto Scaling.
- Click OK.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot