调用updateApplicationScalingRule更新已部署应用的弹性扩缩容策略
接口URL:/v1/app/inst/updateApplicationScalingRule
Content-Type:application/json
请求方式:post
请求体参数说明:
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
appDeployId | String | String | 是 | 应用部署ID,数据来源于已部署应用列表 |
ruleId | String | String | 是 | 策略ID,数据来源于获取弹性扩缩容策略接口 |
name | String | String | 是 | 策略名称,限小写字母开头,小写字母、数字、中划线组成的1到32字符的字符串 |
minReplicas | Integer | Integer | 是 | 最小应用实例数,可选范围: 0 - 1000 |
maxReplicas | Integer | Integer | 是 | 最大应用实例数,可选范围: 2 - 1000 |
trigger | Array | Array | 是 | 触发条件 |
behaviour | Object | Object | 否 | 弹性扩缩容策略 |
userName | String | String | 否 | 用户名 |
tenantId | Long | Long | 否 | 租户ID |
表trigger
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
name | String | String | 是 | 触发器名称 |
type | String | String | 是 | 触发器类型,数据可填写cron和metric |
typeName | String | String | 否 | 触发器类型名称 |
metaData | Object | Object | 是 | 触发器元数据 |
表metaData
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
period | String | String | 否 | 周期类型,可填数据daily、weekly和monthly |
timerInDay | Array | Array | 否 | 按天触发配置列表 |
timerInWeek | Array | Array | 否 | 按周触发 |
timerInMonth | Integer | Integer | 否 | 按月触发 |
metricName | String | String | 否 | 指标类型,可填数据system_cpu、system_mem、incall_qps和incall_rt |
metricDesc | String | String | 否 | 指标描述 |
targetValAvg | Boolean | Boolean | 否 | 按均值计算指标数据 |
targetValue | Integer | Integer | 否 | 目标值 |
metricWindow | Integer | Integer | 否 | 指标聚合时间范围 |
表behaviour
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
scaleDown | Object | Object | 否 | 缩容行为对象 |
scaleUp | Object | Object | 否 | 扩容行为对象 |
表scaleDown/scaleUp
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
selectPolicy | String | String | 是 | 选择策略 |
stabilizationWindowSeconds | Integer | Integer | 是 | 冷却时间 |
policies | Array | Array | 是 | 策略列表,最至少添加1条策略 |
表policies
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
periodSeconds | Integer | Integer | 是 | 扩缩容策略时间周期 |
type | String | String | 是 | 扩缩容策略类型,数据可填写Pods和Percent |
value | Integer | Integer | 是 | 扩缩容策略最大步长/百分比 |
表timerInDay
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
atTime | String | String | 是 | 触发时间,如08:00 |
horizonMode | Boolean | Boolean | 是 | 是否开启实例数量保持 |
targetReplicas | Integer | Integer | 是 | 保持实例数 |
请求示例:
{"appDeployId":"ddbdbfcc-8436-4ad4-9c1f-cdf64f45294b","ruleId":"a526001d-5b40-4651-9adf-35df5490c190","name":"test-scale-rule1","trigger":[{"name":"test-scale-rule-trigger1","type":"cron","metaData":{"period":"daily","timerInDay":[{"atTime":"08:00","horizonMode":true,"targetReplicas":1},{"atTime":"10:00","horizonMode":true,"targetReplicas":0}],"timerInWeek":[],"timerInMonth":[]}}],"maxReplicas":2,"minReplicas":0,"behaviour":{"scaleUp":{"selectPolicy":"Max","stabilizationWindowSeconds":3,"policies":[{"type":"Pods","value":2,"periodSeconds":4}]},"scaleDown":{"selectPolicy":"Min","stabilizationWindowSeconds":5,"policies":[{"type":"Pods","value":2,"periodSeconds":54}]}}}
返回参数说明:
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
statusCode | Integer | Integer | 响应编码 2000 success |
message | String | String | 消息内容 |
returnObj | Object | Object | 返回数据 |
error | String | String | 调用错误时返回的错误编码 |
表returnObj
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
ruleId | String | String | 策略ID |
name | String | String | 策略名称 |
type | String | String | 策略类型 |
enable | Boolean | Boolean | 禁用/启用策略 |
minReplicas | Integer | Integer | 最小应用实例数,可选范围: 0 - 1000 |
maxReplicas | Integer | Integer | 最大应用实例数,可选范围: 2 - 1000 |
trigger | Array | Array | 触发条件配置数组 |
behaviour | Object | Object | 弹性扩缩容策略 |
createTime | String | String | 创建时间 |
createStaff | String | String | 创建用户 |
updateTime | String | String | 更新时间 |
updateStaff | String | String | 更新用户 |
表trigger
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
name | String | String | 触发器名称 |
type | String | String | 触发器类型,包括cron和metric类型 |
typeName | String | String | 触发器类型名称 |
metaData | Object | Object | 触发器元数据 |
表metaData
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
period | String | String | 周期类型,可填数据daily、weekly和monthly |
timerInDay | String | String | 按天触发配置列表 |
timerInWeek | Array | Array | 按周触发 |
timerInMonth | Integer | Integer | 按月触发 |
metricName | String | String | 指标类型,包括system_cpu、system_mem、incall_qps和incall_rt |
metricDesc | String | String | 指标描述 |
targetValAvg | Boolean | Boolean | 按均值计算指标数据 |
targetValue | Integer | Integer | 目标值 |
metricWindow | Integer | Integer | 指标聚合时间范围 |
表behaviour
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
scaleDown | Object | Object | 缩容行为对象 |
scaleUp | Object | Object | 扩容行为对象 |
表scaleDown/scaleUp
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
selectPolicy | String | String | 选择策略 |
stabilizationWindowSeconds | Integer | Integer | 冷却时间 |
policies | Array | Array | 策略列表,最至少添加1条策略 |
表policies
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
periodSeconds | Integer | Integer | 扩缩容策略时间周期 |
type | String | String | 扩缩容策略类型,数据可填写Pods和Percent |
value | Integer | Integer | 扩缩容策略最大步长/百分比 |
返回示例:成功
{"statusCode":2000,"message":"成功","returnObj":{"ruleId":"a526001d-5b40-4651-9adf-35df5490c190","name":"test-scale-rule1","type":"trigger","enable":false,"minReplicas":0,"maxReplicas":2,"trigger":[{"name":"test-scale-rule-trigger1","type":"cron","metaData":{"period":"daily","timerInDay":[{"atTime":"08:00","horizonMode":true,"targetReplicas":1},{"atTime":"10:00","horizonMode":true,"targetReplicas":0}],"timerInWeek":[],"timerInMonth":[]}}],"behaviour":{"scaleDown":{"selectPolicy":"Min","stabilizationWindowSeconds":5,"policies":[{"periodSeconds":54,"type":"Pods","value":2}]},"scaleUp":{"selectPolicy":"Max","stabilizationWindowSeconds":3,"policies":[{"periodSeconds":4,"type":"Pods","value":2}]}},"createTime":"2022-08-30T20:17:19.000+08:00","createStaff":"1234567890@qq.com#测试","updateTime":"2022-08-31T09:13:40.739+08:00","updateStaff":"1234567890@qq.com#测试"}}
返回示例:失败
{"statusCode":190400,"error":"MSAP_400","message":"最大应用实例数不能为空, 最小应用实例数不能为空, 触发条件不能为空. "}