弹性伸缩
更新时间:2026-07-23
接口总览
| 接口名称 | 说明 | 方法 | 路径 |
|---|---|---|---|
| UpdateAutoScaleConfig | 更新弹性伸缩实例配置 | POST | /v2/bcc/autoScaling/[clusterId]/configs/upsert |
| UpdateAutoScaleCapacity | 更新弹性伸缩最大实例数 | POST | /v2/bcc/autoScaling/[clusterId]/capacity/:capacity/update |
| ResetAndReleaseAllInstances | 重置并释放所有伸缩实例 | POST | /v2/bcc/autoScaling/[clusterId]/free |
| GetAutoScalingSummary | 查询伸缩组概览 | POST | /v2/bcc/autoScaling/[clusterId]/detail |
| ListAutoScaleRules | 查询伸缩规则列表 | POST | /v2/bcc/autoScaling/[clusterId]/policies/list |
| CreateAutoScaleRule | 创建伸缩规则 | POST | /v2/bcc/autoScaling/[clusterId]/policies/create |
| ModifyAutoScaleRule | 修改伸缩规则 | POST | /v2/bcc/autoScaling/[clusterId]/policy/:policy_id/update |
| DeleteAutoScaleRule | 删除伸缩规则 | POST | /v2/bcc/autoScaling/[clusterId]/policy/:policy_id/delete |
| SwitchAutoScaleType | 切换弹性伸缩规则类型 | POST | /v2/bcc/autoScaling/[clusterId]/policyType/:policy_type/switch |
UpdateAutoScaleConfig 创建或更新弹性伸缩实例配置
接口描述
创建或更新集群弹性伸缩组的实例类型配置。
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/configs/upsert HTTP/1.1
2Content-Type: application/json
3
4{
5 "isSpot": isSpot,
6 "bidModel": bidModel,
7 "bidPrice": bidPrice,
8 "configurations": [
9 {
10 "type": type,
11 "cpuCore": cpuCore,
12 "memoryInGB": memoryInGB,
13 "rootDiskSizeInGB": rootDiskSizeInGB,
14 "rootMediumType": rootMediumType,
15 "cds": [
16 {
17 "sizeInGB": sizeInGB,
18 "mediumType": mediumType,
19 "attributes": attributes
20 }
21 ],
22 "localDiskCount": localDiskCount,
23 "localDiskType": localDiskType,
24 "localDiskSizeInGB": localDiskSizeInGB
25 }
26 ]
27}
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| configurations | List |
是 | RequestBody | 伸缩实例类型配置列表,元素结构详见数据类型 - AutoScalingConfig |
| isSpot | Boolean | 否 | RequestBody | 是否竞价实例,默认 false |
| bidModel | String | 否 | RequestBody | 竞价模式:market(自动出价)/ custom(设定最高价格) |
| bidPrice | String | 否 | RequestBody | 竞价价格,1 节点/分钟 |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | String | 成功时为空字符串 |
请求示例
JSON
1{
2 "isSpot": false,
3 "bidModel": "",
4 "bidPrice": "",
5 "configurations": [
6 {
7 "type": "bmr.g4.c8m32",
8 "cpuCore": 4,
9 "memoryInGB": 16,
10 "rootDiskSizeInGB": 40,
11 "rootMediumType": "ssd",
12 "cds": [
13 { "sizeInGB": 100, "mediumType": "ssd", "attributes": [] }
14 ],
15 "localDiskCount": 0,
16 "localDiskType": "",
17 "localDiskSizeInGB": 0
18 }
19 ]
20}
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": ""
5}
UpdateAutoScaleCapacity 更新弹性伸缩最大实例数
接口描述
更新弹性伸缩最大的实例数。
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/capacity/:capacity/update HTTP/1.1
2Content-Type: application/json
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| capacity | Int | 是 | URL | 最大实例数 |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | String | 成功时为空字符串 |
请求示例
Plain Text
1POST /v2/bcc/autoScaling/0181b994-576a-4a00-b04e-f6fa9d5eee48/capacity/:capacity/update HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": ""
5}
ResetAndReleaseAllInstances 重置并释放所有伸缩实例
接口描述
释放弹性伸缩组下的所有实例并重置伸缩组。
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/free HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | String | 成功时为空字符串 |
请求示例
Plain Text
1POST /v2/bcc/autoScaling/0181b994-576a-4a00-b04e-f6fa9d5eee48/free HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": ""
5}
GetAutoScalingConfig 查询弹性伸缩配置
接口描述
查询集群的弹性伸缩配置
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/detail HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | List |
伸缩规则列表 |
请求示例
Plain Text
1POST /v2/bcc/autoScaling/0181b994-576a-4a00-b04e-f6fa9d5eee48/detail HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": {
5 "clusterId": "f95f2069-4005-4fa1-a02f-8af7283af68a",
6 "clusterName": "test2",
7 "status": "Idle",
8 "capacity": 2,
9 "maxCapacity": 100,
10 "trickPolicy": "30ae49e6-e381-45a7-aa3d-a35b680bf95d",
11 "type": "timer",
12 "isSpot": false,
13 "availabilityZone": "zoneA",
14 "is_bcc_opened": false,
15 "configurations": [
16 {
17 "type": "bmr.g4.c8m32",
18 "cpuCore": 8,
19 "memoryInGB": 32,
20 "rootMediumType": "ssd",
21 "isSpot": false,
22 "bidModel": "market",
23 "bidPrice": "undefined",
24 "rootDiskSizeInGB": 100,
25 "cds": [
26 {
27 "sizeInGB": 500,
28 "mediumType": "ssd",
29 "attributes": null
30 },
31 {
32 "sizeInGB": 500,
33 "mediumType": "ssd",
34 "attributes": null
35 }
36 ]
37 }
38 ]
39 }
40}
ListAutoScaleRules 查询伸缩规则列表
接口描述
查询集群的弹性伸缩规则(策略)列表。
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/policies/list HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | List |
伸缩规则列表 |
请求示例
Plain Text
1POST /v2/bcc/autoScaling/0181b994-576a-4a00-b04e-f6fa9d5eee48/policies/list HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": [
5 {
6 "policyId": "policy-001",
7 "policyName": "scale-out-on-cpu",
8 "policyAction": "expand",
9 "policyStepNum": 2,
10 "policyEnable": true,
11 "tricking": false,
12 "updateAt": "2026-06-16T12:32:32Z",
13 "policyType": "monitor",
14 "timerExecutionPeriod": "",
15 "timerExecutionTime": "0001-01-01T00:00:00Z",
16 "monitorIndicator": "CpuUsagePercentage",
17 "monitorReference": "",
18 "monitorAction": "biggerThan",
19 "monitorThreshold": 80,
20 "monitorAcquisitionCycle": 5
21 }
22 ]
23}
CreateAutoScaleRule 创建伸缩规则
接口描述
为集群创建一条弹性伸缩规则。
说明:
- 如果正在生效的是【基于时间】的伸缩规则,则无法创建【基于监控】的伸缩规则,反之亦然
- 可创建同名的伸缩规则
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/policies/create HTTP/1.1
2Content-Type: application/json
3
4{
5 "policyName": policyName,
6 "policyAction": policyAction,
7 "policyStepNum": policyStepNum,
8 "policyEnable": policyEnable,
9 "policyType": policyType,
10 "timerExecutionPeriod": timerExecutionPeriod,
11 "timerExecutionTime": timerExecutionTime,
12 "monitorIndicator": monitorIndicator,
13 "monitorReference": monitorReference,
14 "monitorAction": monitorAction,
15 "monitorThreshold": monitorThreshold,
16 "monitorAcquisitionCycle": monitorAcquisitionCycle
17}
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| policyName | String | 是 | RequestBody | 规则名称 |
| policyAction | String | 是 | RequestBody | 伸缩动作(expand / shrink) |
| policyStepNum | Int | 是 | RequestBody | 伸缩步长(实例数) |
| policyType | String | 是 | RequestBody | 规则类型(timer / monitor) |
| policyEnable | Boolean | 是 | RequestBody | 是否启用 |
| timerExecutionPeriod | String | 否 | RequestBody | 定时执行周期(定时类型必填) |
| timerExecutionTime | Time | 否 | RequestBody | 定时执行时间(定时类型必填) |
| monitorIndicator | String | 否 | RequestBody | 监控指标(监控类型必填) |
| monitorReference | String | 否 | RequestBody | 监控参考对象(min / max / average) |
| monitorAction | String | 否 | RequestBody | 监控触发动作(biggerThan / smallerThan) |
| monitorThreshold | Int | 否 | RequestBody | 监控阈值,取值范围 [0, 100] |
| monitorAcquisitionCycle | Int | 否 | RequestBody | 监控采集周期,单位为分钟,取值范围 [5, 20] |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | String | 成功时为空字符串 |
请求示例
JSON
1{
2 "policyName": "scale-out-on-cpu",
3 "policyAction": "expand",
4 "policyStepNum": 2,
5 "policyEnable": true,
6 "policyType": "monitor",
7 "timerExecutionPeriod": "",
8 "timerExecutionTime": "0001-01-01T00:00:00Z",
9 "monitorIndicator": "CpuUsagePercentage",
10 "monitorReference": "",
11 "monitorAction": "biggerThan",
12 "monitorThreshold": 80,
13 "monitorAcquisitionCycle": 5
14}
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": ""
5}
ModifyAutoScaleRule 修改伸缩规则
接口描述
修改集群的某条弹性伸缩规则。
说明:如果正在生效的是【基于时间】的伸缩规则,则无法修改【基于监控】的伸缩规则,反之亦然。
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/policy/:policy_id/update HTTP/1.1
2Content-Type: application/json
3
4{
5 "policyName": policyName,
6 "policyAction": policyAction,
7 "policyStepNum": policyStepNum,
8 "policyEnable": policyEnable,
9 "policyType": policyType,
10 "timerExecutionPeriod": timerExecutionPeriod,
11 "timerExecutionTime": timerExecutionTime,
12 "monitorIndicator": monitorIndicator,
13 "monitorReference": monitorReference,
14 "monitorAction": monitorAction,
15 "monitorThreshold": monitorThreshold,
16 "monitorAcquisitionCycle": monitorAcquisitionCycle
17}
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| policy_id | String | 是 | URL | 规则 ID |
| policyName | String | 是 | RequestBody | 规则名称 |
| policyAction | String | 是 | RequestBody | 伸缩动作(expand / shrink) |
| policyStepNum | Int | 是 | RequestBody | 伸缩步长(实例数) |
| policyType | String | 是 | RequestBody | 规则类型(timer / monitor) |
| policyEnable | Boolean | 是 | RequestBody | 是否启用 |
| timerExecutionPeriod | String | 否 | RequestBody | 定时执行周期(定时类型必填) |
| timerExecutionTime | Time | 否 | RequestBody | 定时执行时间(定时类型必填) |
| monitorIndicator | String | 否 | RequestBody | 监控指标(监控类型必填) |
| monitorReference | String | 否 | RequestBody | 监控参考对象(min / max / average) |
| monitorAction | String | 否 | RequestBody | 监控触发动作(biggerThan / smallerThan) |
| monitorThreshold | Int | 否 | RequestBody | 监控阈值,取值范围 [0, 100] |
| monitorAcquisitionCycle | Int | 否 | RequestBody | 监控采集周期,单位为分钟,取值范围 [5, 20] |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | String | 成功时为空字符串 |
请求示例
JSON
1{
2 "policyName": "scale-out-on-cpu",
3 "policyAction": "expand",
4 "policyStepNum": 3,
5 "policyEnable": true,
6 "policyType": "monitor",
7 "timerExecutionPeriod": "",
8 "timerExecutionTime": "0001-01-01T00:00:00Z",
9 "monitorIndicator": "CpuUsagePercentage",
10 "monitorReference": "",
11 "monitorAction": "biggerThan",
12 "monitorThreshold": 85,
13 "monitorAcquisitionCycle": 5
14}
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": ""
5}
DeleteAutoScaleRule 删除伸缩规则
接口描述
删除集群的某条弹性伸缩规则。
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/policy/:policy_id/delete HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| policy_id | String | 是 | URL | 规则 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | String | 成功时为空字符串 |
请求示例
Plain Text
1POST /v2/bcc/autoScaling/0181b994-576a-4a00-b04e-f6fa9d5eee48/policy/policy-001/delete HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": ""
5}
SwitchAutoScaleType 切换弹性伸缩规则类型
接口描述
切换弹性伸缩规则类型。
请求结构
Plain Text
1POST /v2/bcc/autoScaling/[clusterId]/policyType/:policy_type/switch HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| policy_type | String | 是 | URL | 切换的规则类型:monitor(监控指标)/ timer(时间规则) |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | String | 成功时为空字符串 |
请求示例
Plain Text
1POST /v2/bcc/autoScaling/0181b994-576a-4a00-b04e-f6fa9d5eee48/policyType/monitor/switch HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": ""
5}
错误码
| HTTP Status | Code | Message | 说明 |
|---|---|---|---|
| 400 | MalformedJSON | The JSON provided is not well-formed | 请求体不是合法 JSON,参数绑定失败 |
| 400 | InvalidParameter | Invalid request parameter | 请求参数不合法,常见场景:capacity 越界、伸缩配置为空、伸缩动作非 expand/shrink、伸缩步长 ≤ 0、policyType 非 timer/monitor、定时周期不在 once/daily/weekly/monthly 之内、monitorReference 非 min/max/average、monitorAcquisitionCycle 不在 [5,20]、monitorThreshold 不在 [0,100] 等 |
| 401 | Unauthorized | Check unauthorized | 身份未认证或认证失败 |
| 403 | AccessDenied | Access denied, please contact your administrator | 无对应操作权限(IAM 或 Console 鉴权拒绝) |
| 403 | OperateForbid | The requested operation is forbidden for this resource | 当前伸缩节点组状态不允许执行该操作(如修改伸缩规则时节点组尚未就绪) |
| 404 | ClusterNotFound | The cluster not found | clusterId 对应的集群不存在 |
| 429 | RequestLimited | Request frequency is too high, please slow down and try again later | 请求频率过高,被限流 |
| 500 | InternalError | Internal Server Error | 服务内部错误(如数据库查询失败、依赖服务异常等) |
| 503 | ServiceUnavailable | Service is unavailable | 服务不可用或当前状态不允许操作,常见场景:伸缩组正在 resizing 时执行释放;存在已启用的伸缩规则时执行释放或切换规则类型;集群尚未创建伸缩节点组时创建规则等 |
评价此篇文章
