Updated on 2023-12-19 GMT+08:00

Viewing Auto Scaling Policies

Function

This API is used to view all auto scaling policies of a specified cluster.

Constraints

None

Debugging

You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and provide the sample SDK code debugging.

URI

GET /v2/{project_id}/autoscaling-policy/{cluster_id}

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

The project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

cluster_id

Yes

String

The cluster ID. For details about how to obtain the cluster ID, see Obtaining a Cluster ID.

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameter

Parameter

Type

Description

[Array element]

Array of AutoScalingPolicyV2 objects

The auto scaling policy list. For details, see Table 3.

Table 3 AutoScalingPolicyV2

Parameter

Type

Description

node_group_name

String

The node group name. This parameter is mandatory. If resource_pool_name is default, the auto scaling policies are created by node group. If resource_pool_name is not default, policies of the resource pool corresponding to the node group are created.

resource_pool_name

String

The resource plan name. This parameter is mandatory. If the cluster version does not support auto scaling for a specified resource pool, set this parameter to default. If this parameter is not default, the auto scaling policy of the specified resource pool is deleted.

auto_scaling_policy

AutoScalingPolicyInfo object

The auto scaling policy. For details, see Table 4.

Table 4 AutoScalingPolicyInfo

Parameter

Type

Description

auto_scaling_enable

Boolean

Whether to enable the auto scaling policy.

min_capacity

Integer

The minimum number of nodes reserved in the node group. The value ranges from 0 to 500.

max_capacity

Integer

The maximum number of nodes in the node group. The value ranges from 0 to 500.

resources_plans

Array of ResourcesPlan objects

The resource plan list. If this parameter is left blank, the resource plan is disabled. When auto_scaling_enable is set to true, either this parameter or rules must be configured. For details about this parameter, see Table 5.

rules

Array of Rule objects

List of auto scaling rules. When auto_scaling_enable is set to true, either this parameter or resources_plans must be configured. For details about this parameter, see Table 6.

tags

Array of Tag objects

Auto scaling tags. For details, see Table 8.

Table 5 ResourcesPlan

Parameter

Type

Description

period_type

String

The cycle type of a resource plan. Currently, only the following cycle type is supported:

daily

start_time

String

The start time of a resource plan. The value is in the format of hour:minute, indicating that the time ranges from 00:00 to 23:59.

end_time

String

The end time of a resource plan. The value is in the same format as that of start_time. The interval between end_time and start_time must be greater than or equal to 30 minutes.

min_capacity

Integer

The minimum number of reserved nodes in a node group in a resource plan. The value ranges from 0 to 500.

max_capacity

Integer

The maximum number of reserved nodes in a node group in a resource plan. The value ranges from 0 to 500.

effective_days

Array of strings

Effective date of a resource plan. If this parameter is left blank, it indicates that the resource plan takes effect every day. The options are as follows:

MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, and SUNDAY

Table 6 Rule

Parameter

Type

Description

name

String

The name of an auto scaling rule. The name can contain only 1 to 64 characters. Only letters, numbers, hyphens (-), and underscores (_) are allowed. Rule names must be unique in a node group.

description

String

The description about an auto scaling rule. It contains a maximum of 1,024 characters.

adjustment_type

String

Auto scaling rule adjustment type. Possible values:

  • scale_out: cluster scale-out
  • scale_in: cluster scale-in

cool_down_minutes

Integer

The cluster cooling time after an auto scaling rule is triggered, when no auto scaling operation is performed. The unit is minute. The value ranges from 0 to 10080. One week is equal to 10,080 minutes.

scaling_adjustment

Integer

The number of cluster nodes that can be adjusted at a time. The value ranges from 1 to 100.

trigger

Trigger object

The condition for triggering a rule. For details, see Table 7.

Table 7 Trigger

Parameter

Type

Description

metric_name

String

The metric name. This triggering condition makes a judgment according to the value of the metric. A metric name contains a maximum of 64 characters.

metric_value

String

The metric threshold to trigger a rule.

The value must be an integer or a number with two decimal places.

comparison_operator

String

The metric judgment logic operator. Possible values:

  • LT: less than
  • GT: greater than
  • LTOE: less than or equal to
  • GTOE: greater than or equal to

evaluation_periods

Integer

The number of consecutive five-minute periods, during which a metric threshold is reached. The value ranges from 1 to 288.

Table 8 Tag

Parameter

Type

Description

key

String

Tag key

  • The tag key can contain a maximum of 36 Unicode characters and cannot be an empty string.
  • The tag key cannot start or end with spaces or contain non-printable ASCII characters (0–31) and special characters (=*<>\,|/).
  • The tag key of a resource must be unique.

value

String

Tag value

  • The value can contain 0 to 43 unicode characters.
  • The tag value cannot start or end with spaces or contain non-printable ASCII characters (0–31) and special characters (=*<>\,|/).

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error codes.

error_msg

String

The error message.

Example Request

None

Example Response

Status code: 200

Auto scaling policies are displayed.

{
  "auto_scaling_policies" : [ {
    "node_group_name" : "task_node_analysis_group",
    "resource_pool_name" : "default",
    "auto_scaling_policy" : {
      "auto_scaling_enable" : true,
      "min_capacity" : 0,
      "max_capacity" : 1,
      "resources_plans" : [ {
        "period_type" : "daily",
        "effective_days" : [ "SUNDAY" ],
        "start_time" : "12:00",
        "end_time" : "13:00",
        "min_capacity" : 2,
        "max_capacity" : 3
      } ],
      "rules" : [ {
        "name" : "default-expand-1",
        "description" : "",
        "adjustment_type" : "scale_out",
        "cool_down_minutes" : 5,
        "scaling_adjustment" : 1,
        "trigger" : {
          "metric_name" : "YARNAppRunning",
          "metric_value" : 100,
          "comparison_operator" : "GTOE",
          "evaluation_periods" : 1
        }
      } ]
    }
  } ]
}

Status Codes

See Status Codes.

Error Codes

See Error Codes.