-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathACS-ESS-AdjustScalingGroupInstanceCount.yml
472 lines (472 loc) · 15.8 KB
/
ACS-ESS-AdjustScalingGroupInstanceCount.yml
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
FormatVersion: OOS-2019-06-01
Description:
en: <p class="p">Adjust the number of instances in a scaling group by creating and executing scaling group rules. Description:</p>
<ul class="ul">
<li class="li">If the scaling group has been configured with the desired number of instances, when the number of instances in the scaling group is not equal to the expected number of instances, the auto scaling service will automatically scale to ensure that the number of instances in the scaling group is always maintained After the execution is complete, please go to the ESS console to view the adjustment results. </li>
<li class="li">The number of cluster nodes after scaling down the nodes cannot be less than the minimum node requirements of the component, otherwise the scaling operation may return an error of code:IncorrectCapacity. </li>
<li class="li">Please ensure that your account balance is greater than the cost of the newly purchased instance, otherwise an error of code:InvalidAccountStatus.NotEnoughBalance will be returned. </li>
<li class="li">If it is multi-zone, please expand the multiple of the number of zones. </li>
<li class="li">The payment method for the expanded ECS is pay-as-you-go. If necessary, customers need to Manual subcontracting yearly and monthly. </a></li>
<li class="li"> There are two ways to scale down:scale down the specified number of ECS (<b>the number of ECS instance adjustments in the scaling group</b> is not 0), remove the specified ECS from the scaling group ( <b>The number of ECS instance adjustments in the scaling group</b> is 0 and the ECS to be removed is selected)</li>
<li class="li">The scaling cannot be less than the number initially opened in the scaling group. </li>
</ul>
<p class="p">Adjust the number of instances in a scaling group by creating and executing scaling group rules. Description:</p>
<ul class="ul">
<li class="li">Adjust ACK cluster node pool<a href='https://help.aliyun.com/document_detail/160490.html?spm=5176.2020520152.help.dexternal.253916ddpJbWDl#title-mpp-3jj- oo3'>Expected number of nodes</a>, please read the linked document carefully and authorize the role AliyunOOSLifecycleHook4CSRole. </li>
</ul>
zh-cn: <p class="p">通过创建并执行伸缩组规则来调整伸缩组的实例数。说明:</p>
<ul class="ul">
<li class="li">如果伸缩组已配置期望实例数,当伸缩组内实例数不等于期望实例数时,弹性伸缩服务会自动进行扩缩容,确保伸缩组内始终保持该数量的实例数,执行完毕后请到ESS控制台查看调整结果。</li>
<li class="li">缩容节点后的集群节点数量,不能小于组件最低节点要求,否则缩容操作可能会返回 code:IncorrectCapacity 的错误。</li>
<li class="li">执行请确保您的账号余额大于新购实例的费用,否则会返回 code:InvalidAccountStatus.NotEnoughBalance 的错误。</li>
<li class="li">如果是多可用区请扩容可用区数的倍数。</li>
<li class="li">扩容的ECS付费方式为按量付费,如有需要,客户需要手动<a href="https://help.aliyun.com/document_detail/49884.html?spm=5176.2020520101.help.dexternal.6ecb4df5sxWQrt">转包年包月。</a></li>
<li class="li">缩容有两种方式:缩容指定数量的ECS(<b>伸缩组ECS实例调整的数量</b>非0)、从伸缩组中移除指定的ECS(<b>伸缩组ECS实例调整的数量</b>为0且选择要移除的ECS)</li>
<li class="li">缩容数量不能少于伸缩组内最开始开出来的数量。</li>
</ul>
<p class="p">调整ACK集群节点池<a href='https://help.aliyun.com/document_detail/160490.html?spm=5176.2020520152.help.dexternal.253916ddpJbWDl#title-mpp-3jj-oo3'>期望节点数</a>。说明:</p>
<ul class="ul">
<li class="li">请仔细阅读链接文档并授权角色AliyunOOSLifecycleHook4CSRole。</li>
</ul>
name-en: Elastic Scaling
name-zh-cn: 弹性扩缩容
categories:
- elastic_manage
- application_manage
- computenest
Parameters:
resourceType:
Type: String
Label:
en: ResourceType
zh-cn: 将要调整的资源类型
AllowedValues:
- ACK
- ESS
Default: ESS
regionId:
Type: String
Label:
en: RegionId
zh-cn: 将要克隆的ECS实例所在地域
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
scalingGroupId:
Type: String
Label:
en: ScalingGroupId
zh-cn: 伸缩组ID
Default: ''
AssociationProperty: ALIYUN::ESS::AutoScalingGroup::AutoScalingGroupId
AssociationPropertyMetadata:
RegionId: regionId
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ESS
adjustmentType:
Type: String
Label:
en: AdjustmentType
zh-cn: 伸缩规则的调整方式
AssociationPropertyMetadata:
LocaleKey: ESSGroupAdjustmentType
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ESS
AllowedValues:
- ScaleOut
- ScaleIn
- TotalCapacity
Default: ScaleOut
adjustmentCount:
Type: Number
Label:
en: AdjustmentCount
zh-cn: 伸缩组ECS实例调整的数量
MinValue: 0
MaxValue: 100
Default: 0
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ESS
instancesToBeRemoved:
Type: Json
Label:
en: RemovedInstances
zh-cn: 从伸缩组中移除的ECS实例
Default:
Type: ResourceIds
ResourceIds: []
RegionId: '{{ ACS::RegionId }}'
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
RegionId: regionId
Visible:
Condition:
Fn::And:
- Fn::Equals:
- '${resourceType}'
- ESS
- Fn::Equals:
- '${adjustmentType}'
- ScaleIn
- Fn::Equals:
- '${adjustmentCount}'
- 0
clusterId:
Label:
en: ClusterId
zh-cn: 集群ID
Type: String
Default: ''
AssociationProperty: ALIYUN::CS::Cluster::ClusterId
AssociationPropertyMetadata:
RegionId: ${regionId}
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ACK
nodepoolId:
Label:
en: NodepoolId
zh-cn: 节点池ID
Type: String
Default: ''
AssociationProperty: ALIYUN::CS::Cluster::ClusterNodePool
AssociationPropertyMetadata:
RegionId: ${regionId}
ClusterId: ${clusterId}
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ACK
desiredSize:
Label:
en: DesiredSize
zh-cn: 期望节点数
Type: Number
MinValue: 0
MaxValue: 100
Default: 0
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ACK
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: chooseNextTaskByResourceType
Action: 'ACS::Choice'
Description:
en: Choose next task by resource type
zh-cn: 根据资源类型选择下一个任务
Properties:
DefaultTask: whetherToRemoveInstancesFromScalingGroup
Choices:
- When:
Fn::Equals:
- 'ACK'
- '{{ resourceType }}'
NextTask: getNodePoolDetail
- Name: whetherToRemoveInstancesFromScalingGroup
Action: 'ACS::Choice'
Description:
en: Choose next task by adjustment type
zh-cn: 根据伸缩规则调整方式选择下一个任务
Properties:
DefaultTask: createScalingRule
Choices:
- When:
Fn::And:
- Fn::Equals:
- '{{adjustmentType}}'
- ScaleIn
- Fn::Equals:
- '{{adjustmentCount}}'
- 0
NextTask: getInstanceToBeRemoved
- Name: getInstanceToBeRemoved
Description:
en: Get the ECS instance to be removed
zh-cn: 获取待移除的ECS实例
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{ regionId }}'
Filters:
- '{{ instancesToBeRemoved }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: removeInstances
Action: 'ACS::ExecuteAPI'
OnSuccess: waitScalingActivityComplete
When:
Fn::Not:
Fn::Equals:
- '{{ getInstanceToBeRemoved.instanceIds }}'
- []
Description:
en: Remove instances from scaling group
zh-cn: 从伸缩组中移除ECS实例
Properties:
Service: ESS
API: RemoveInstances
Parameters:
RegionId: '{{ regionId }}'
ScalingGroupId: '{{ scalingGroupId }}'
InstanceIds: '{{ getInstanceToBeRemoved.instanceIds }}'
Outputs:
scalingActivityId:
Type: String
ValueSelector: .ScalingActivityId
- Name: createScalingRule
Action: 'ACS::ExecuteAPI'
Description:
en: Create a ScalingRule
zh-cn: 创建伸缩规则
Properties:
Service: ESS
API: CreateScalingRule
Parameters:
RegionId: '{{ regionId }}'
ScalingGroupId: '{{ scalingGroupId }}'
ScalingRuleName: '{{ ACS::ExecutionId }}'
AdjustmentType:
Fn::If:
- Fn::Equals:
- 'TotalCapacity'
- '{{ adjustmentType }}'
- TotalCapacity
- QuantityChangeInCapacity
AdjustmentValue:
Fn::If:
- Fn::Equals:
- ScaleIn
- '{{ adjustmentType }}'
- '-{{ adjustmentCount }}'
- '{{ adjustmentCount }}'
Outputs:
scalingRuleAri:
Type: String
ValueSelector: ScalingRuleAri
scalingRuleId:
Type: String
ValueSelector: ScalingRuleId
- Name: executeScalingRule
Description:
en: Execute the ScalingRule
zh-cn: 执行伸缩规则
OnError: deleteScalingRule
Action: 'ACS::ExecuteApi'
Properties:
Service: ESS
API: ExecuteScalingRule
Parameters:
RegionId: '{{ regionId }}'
ScalingRuleAri: '{{ createScalingRule.scalingRuleAri }}'
Outputs:
scalingActivityId:
Type: String
ValueSelector: ScalingActivityId
- Name: waitScalingActivityComplete
Description:
en: Poll scaling activity execution until success or failure
zh-cn: 轮询伸缩活动执行情况直到成功或者失败
OnError: deleteScalingRule
Retries: 30
Action: 'ACS::WaitFor'
Properties:
Service: ESS
API: DescribeScalingActivities
Parameters:
RegionId: '{{ regionId }}'
ScalingActivityId1:
Fn::If:
- Fn::And:
- Fn::Equals:
- '{{adjustmentType}}'
- ScaleIn
- Fn::Equals:
- '{{adjustmentCount}}'
- 0
- '{{ removeInstances.scalingActivityId }}'
- '{{ executeScalingRule.scalingActivityId }}'
DesiredValues:
- Successful
StopRetryValues:
- Failed
- Rejected
- Warning
PropertySelector: 'ScalingActivities.ScalingActivity[0].StatusCode'
- Name: deleteScalingRule
When:
Fn::Not:
Fn::And:
- Fn::Equals:
- '{{adjustmentType}}'
- ScaleIn
- Fn::Equals:
- '{{adjustmentCount}}'
- 0
Description:
en: Delete ScalingRule
zh-cn: 删除伸缩组规则
Action: 'ACS::ExecuteApi'
Properties:
Service: ESS
API: DeleteScalingRule
Parameters:
RegionId: '{{ regionId }}'
ScalingRuleId: '{{ createScalingRule.scalingRuleId }}'
- Name: describeScalingActivityDetail
Description:
en: Describe scaling activity detail
zh-cn: 查询一个伸缩活动的详细信息
Action: 'ACS::ExecuteApi'
Properties:
Service: ESS
API: DescribeScalingActivityDetail
Parameters:
RegionId: '{{ regionId }}'
ScalingActivityId:
Fn::If:
- Fn::And:
- Fn::Equals:
- '{{adjustmentType}}'
- ScaleIn
- Fn::Equals:
- '{{adjustmentCount}}'
- 0
- '{{ removeInstances.scalingActivityId }}'
- '{{ executeScalingRule.scalingActivityId }}'
Outputs:
detail:
Type: String
ValueSelector: .Detail
- Name: getOOSExecutionOutput
Action: 'ACS::ExecuteAPI'
OnSuccess: ACS::END
Description:
en: Get the lifecycle hook OOS execution output
zh-cn: 获取生命周期挂钩OOS执行的输出
Properties:
Service: OOS
API: ListExecutions
Parameters:
RegionId: '{{ regionId }}'
Tags:
ESS:ScalingActivityId:
Fn::If:
- Fn::And:
- Fn::Equals:
- '{{adjustmentType}}'
- ScaleIn
- Fn::Equals:
- '{{adjustmentCount}}'
- 0
- '{{ removeInstances.scalingActivityId }}'
- '{{ executeScalingRule.scalingActivityId }}'
Outputs:
lifecycleHookOOSExecutionResult:
Type: String
ValueSelector: 'Executions[].Outputs'
- Name: getNodePoolDetail
Action: ACS::WaitFor
Description:
en: Get cluster node pool info
zh-cn: 获取集群节点池信息
Retries: 20
Properties:
Service: CS
API: DescribeClusterNodePoolDetail
Method: GET
URI: /clusters/{{clusterId}}/nodepools/{{nodepoolId}}
Parameters: {}
DesiredValues:
- active
PropertySelector: .status.state
Outputs:
nodePoolInfo:
Type: Json
ValueSelector: .
- Name: modifyClusterNodePool
Action: ACS::ExecuteAPI
Description:
en: Modify cluster node pool configuration
zh-cn: 修改集群节点池配置
Properties:
Service: CS
API: ModifyClusterNodePool
Method: PUT
Headers:
Content-Type: application/json
URI: /clusters/{{clusterId}}/nodepools/{{nodepoolId}}
Body:
Fn::Jq:
- First
- '.+({"scaling_group": (.scaling_group + {"desired_size": {{desiredSize}}})}) | del(.scaling_group.login_password)'
- '{{ getNodePoolDetail.nodePoolInfo }}'
- Name: untilClusterNodePoolReady
Action: ACS::WaitFor
Description:
en: Wait for the cluster node pool configuration to complete
zh-cn: 等待集群节点池配置修改完成
Retries: 20
Properties:
Service: CS
API: DescribeClusterNodePoolDetail
Method: GET
Parameters: {}
URI: /clusters/{{clusterId}}/nodepools/{{nodepoolId}}
DesiredValues:
- active
PropertySelector: .status.state
Outputs:
adjustDetail:
Type: String
Value: '{{ describeScalingActivityDetail.detail }}'
lifecycleHookOOSExecutionResult:
Type: String
Value: '{{ getOOSExecutionOutput.lifecycleHookOOSExecutionResult }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- resourceType
- scalingGroupId
- adjustmentType
- adjustmentCount
- instancesToBeRemoved
- clusterId
- nodepoolId
- desiredSize
Label:
default:
zh-cn: 调整方式设置
en: Scaling Rule Configure Parameters
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: 高级选项
en: Control Options