查看弹性伸缩策略
功能介绍
查看指定集群的所有的弹性伸缩策略信息。
接口约束
无
调用方法
请参见如何调用API。
URI
GET /v2/{project_id}/autoscaling-policy/{cluster_id}
请求参数
无
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
[数组元素] |
Array of AutoScalingPolicyV2 objects |
弹性伸缩策略列表 |
参数 |
参数类型 |
描述 |
---|---|---|
node_group_name |
String |
节点组名称。必填参数。如果resource_pool_name为default,则创建节点组维度的弹性伸缩策略。如果resource_pool_name不为default,则在该节点组下创建对应资源池维度的策略。 |
resource_pool_name |
String |
资源池名称。必填参数。当集群版本不支持按指定资源池进行弹性伸缩时,需要填写为default资源池。不为default时删除指定资源池维度的弹性伸缩策略。 |
auto_scaling_policy |
AutoScalingPolicyInfo object |
弹性伸缩规则。 |
参数 |
参数类型 |
描述 |
---|---|---|
auto_scaling_enable |
Boolean |
当前自动伸缩规则是否开启。 |
min_capacity |
Integer |
指定该节点组的最小保留节点数。 取值范围:[0~500] |
max_capacity |
Integer |
指定该节点组的最大节点数。 取值范围:[0~500] |
resources_plans |
Array of ResourcesPlan objects |
资源计划列表。若该参数为空表示不启用资源计划。 当启用弹性伸缩时,资源计划与自动伸缩规则需至少配置其中一种。 |
rules |
Array of Rule objects |
自动伸缩的规则列表。当启用弹性伸缩时,资源计划与自动伸缩规则需至少配置其中一种。 |
tags |
Array of Tag objects |
弹性伸缩标签列表 |
参数 |
参数类型 |
描述 |
---|---|---|
period_type |
String |
资源计划的周期类型,当前只允许以下类型: daily |
start_time |
String |
资源计划的起始时间,格式为“hour:minute”,表示时间在0:00-23:59之间。 |
end_time |
String |
资源计划的结束时间,格式与“start_time”相同,不早于start_time表示的时间,且与start_time间隔不小于30min。 |
min_capacity |
Integer |
资源计划内该节点组的最小保留节点数。 取值范围:[0~500] |
max_capacity |
Integer |
资源计划内该节点组的最大保留节点数。 取值范围:[0~500] |
effective_days |
Array of strings |
资源计划的生效日期,为空时代表每日,另外也可为以下返回值: MONDAY(周一)、TUESDAY(周二)、WEDNESDAY(周三)、THURSDAY(周四)、FRIDAY(周五)、SATURDAY(周六)、SUNDAY(周日) |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
弹性伸缩规则的名称。 只能由字母、数字、中划线和下划线组成,并且长度为1~64个字符。 在一个节点组范围内,不允许重名。 |
description |
String |
弹性伸缩规则的说明。 最大长度为1024字符。 |
adjustment_type |
String |
弹性伸缩规则的调整类型,只允许以下类型: 枚举值:
|
cool_down_minutes |
Integer |
触发弹性伸缩规则后,该集群处于冷却状态(不再执行弹性伸缩操作)的时长,单位为分钟。 取值范围[0~10080],10080为一周的分钟数。 |
scaling_adjustment |
Integer |
单次调整集群节点的个数。 取值范围[1~100] |
trigger |
Trigger object |
描述该规则触发条件。 |
参数 |
参数类型 |
描述 |
---|---|---|
metric_name |
String |
指标名称。 该触发条件会依据该名称对应指标的值来进行判断。 最大长度为64个字符。 |
metric_value |
String |
指标阈值。 触发该条件的指标阈值,只允许输入整数或者带两位小数的数。 |
comparison_operator |
String |
指标判断逻辑运算符,包括:
|
evaluation_periods |
Integer |
判断连续满足指标阈值的周期数(一个周期为5分钟)。 取值范围[1~288] |
参数 |
参数类型 |
描述 |
---|---|---|
key |
String |
键。
|
value |
String |
值。
|
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码 |
error_msg |
String |
错误描述 |
请求示例
无
响应示例
状态码: 200
查看弹性伸缩策略成功
[ { "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 } } ] } } ]
SDK代码示例
SDK代码示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.mrs.v2.region.MrsRegion; import com.huaweicloud.sdk.mrs.v2.*; import com.huaweicloud.sdk.mrs.v2.model.*; public class ShowAutoScalingPolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); ShowAutoScalingPolicyRequest request = new ShowAutoScalingPolicyRequest(); try { ShowAutoScalingPolicyResponse response = client.showAutoScalingPolicy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v2.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = ShowAutoScalingPolicyRequest() response = client.show_auto_scaling_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ShowAutoScalingPolicyRequest{} response, err := client.ShowAutoScalingPolicy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
查看弹性伸缩策略成功 |
400 |
查看弹性伸缩策略失败 |
错误码
请参见错误码。