Help Center> Cloud Container Engine> User Guide> Old Console> Auto Scaling> Scaling a Workload> Creating a CustomedHPA Policy for Workload Auto Scaling
Updated on 2022-12-30 GMT+08:00

Creating a CustomedHPA Policy for Workload Auto Scaling

A CustomedHPA policy scales Deployments based on metrics (such as CPU usage and memory usage) or at a periodic interval (a specific time point every day, every week, every month, or every year). This type of policy is a CCE-enhanced auto scaling capability.

Supported functions:
  • Scaling can be performed based on the percentage of the current number of pods.
  • The minimum scaling step can be set.
  • Different scaling operations can be performed based on the actual metric values.

Prerequisites

To use a CustomedHPA policy, you must install the cce-hpa-controller add-on. If the cce-hpa-controller version is earlier than 1.2.11, the prometheus add-on must be installed. If the cce-hpa-controller version is 1.2.11 or later, the add-ons that can provide metrics API, such as metrics-server and prometheus, must be installed.

Notes and Constraints

  • CustomedHPA policies can be created only for clusters of v1.15 or later.
  • Only one policy can be created for each workload. If you have created an HPA policy, you cannot create a CustomedHPA policy or 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

  1. Log in to the CCE console. In the navigation pane, choose Auto Scaling. On the Workload Scaling tab page, click Create CustomedHPA Policy.
  2. In the Check Add-ons step:

    • If is displayed next to the add-on name, click Install, set add-on parameters as required, and click Install to install the add-on.
    • If is displayed next to the add-on name, the add-on has been installed.

  3. After the required add-ons have been installed, click Next: Policy configuration.

    If the add-ons have been installed, after you click Create CustomedHPA Policy, you will directly land on the second step to configure the policy. The first step (checking the add-ons) has been completed almost instantly.

  4. Set policy parameters by referring to Table 1.

    Table 1 CustomedHPA 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 CustomedHPA 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

    Enter an interval, in minutes.

    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

    Click Add Rule. In the dialog box displayed, set the following parameters:

    • Name: Enter a custom rule name.
    • Type: You can select Metric-based or Periodic.

    Metric-based:

    • Condition: Select CPU usage or Memory usage, choose > or <, and enter a percentage. As shown in the following figure, the rule will be executed immediately when the CPU usage is greater than 50%.
      NOTE:

      Usage = CPUs or memory used by pods/Requested CPUs or memory.

      Figure 1 Setting a trigger condition
    • Action: Set an action to be performed when the trigger condition is met. Multiple actions can be added. As shown below, when the CPU usage exceeds 50%, the number of pods is scaled out to 5. When the CPU usage exceeds 70%, the number of pods is scaled out to 8. When the CPU usage exceeds 90%, the number of pods is scaled out to 18 (adding 10 more pods). These rules also work for scale-in operations.
      Figure 2 Action
    • Enable: Enable or disable the policy rule.

    Periodic:

    • Triggered At: You can select a specific time point every day, every week, every month, or every year. As shown below, the rule is triggered at 17:00 every day.
      Figure 3 Periodic triggering (Daily)
    • Action: Set an action to be performed when the Triggered At value is reached. As shown below, four pods will be reduced at 17:00 every day.
      Figure 4 Setting an action for periodic triggering
    • Enable: Enable or disable the policy rule.

    Click OK. You can view the added rule in the policy rule list and enable, disable, edit, or delete the rule.

    You can click Add Rule below the policy rule list to add multiple rules.

  5. 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.
  6. On the Workload Scaling tab page, you can view the newly created CustomedHPA policy.

    Figure 5 Creating a CustomedHPA policy