ACS-ESS-AdjustScalingGroupInstanceCount
模板名稱
ACS-ESS-AdjustScalingGroupInstanceCount 彈性擴(kuò)縮容
模板描述
通過創(chuàng)建并執(zhí)行伸縮組規(guī)則來調(diào)整伸縮組的實(shí)例數(shù)。說明:
如果伸縮組已配置期望實(shí)例數(shù),當(dāng)伸縮組內(nèi)實(shí)例數(shù)不等于期望實(shí)例數(shù)時(shí),彈性伸縮服務(wù)會(huì)自動(dòng)進(jìn)行擴(kuò)縮容,確保伸縮組內(nèi)始終保持該數(shù)量的實(shí)例數(shù),執(zhí)行完畢后請(qǐng)到ESS控制臺(tái)查看調(diào)整結(jié)果。
縮容節(jié)點(diǎn)后的集群節(jié)點(diǎn)數(shù)量,不能小于組件最低節(jié)點(diǎn)要求,否則縮容操作可能會(huì)返回 code:IncorrectCapacity 的錯(cuò)誤。
執(zhí)行請(qǐng)確保您的賬號(hào)余額大于新購實(shí)例的費(fèi)用,否則會(huì)返回 code:InvalidAccountStatus.NotEnoughBalance 的錯(cuò)誤。
如果是多可用區(qū)請(qǐng)擴(kuò)容可用區(qū)數(shù)的倍數(shù)。
擴(kuò)容的ECS付費(fèi)方式為按量付費(fèi),如有需要,客戶需要手動(dòng)按量付費(fèi)轉(zhuǎn)包年包月
縮容有兩種方式:縮容指定數(shù)量的ECS(伸縮組ECS實(shí)例調(diào)整的數(shù)量非0)、從伸縮組中移除指定的ECS(伸縮組ECS實(shí)例調(diào)整的數(shù)量為0且選擇要移除的ECS)
縮容數(shù)量不能少于伸縮組內(nèi)最開始開出來的數(shù)量。
調(diào)整ACK集群節(jié)點(diǎn)池創(chuàng)建節(jié)點(diǎn)池。說明:
請(qǐng)仔細(xì)閱讀鏈接文檔并授權(quán)角色AliyunOOSLifecycleHook4CSRole。
模板類型
自動(dòng)化
所有者
Alibaba Cloud
輸入?yún)?shù)
參數(shù)名稱 | 描述 | 類型 | 是否必填 | 默認(rèn)值 | 約束 |
resourceType | 將要調(diào)整的資源類型 | String | 否 | ESS | |
regionId | 將要克隆的ECS實(shí)例所在地域 | String | 否 | {{ ACS::RegionId }} | |
scalingGroupId | 伸縮組ID | String | 否 | "" | |
adjustmentType | 伸縮規(guī)則的調(diào)整方式 | String | 否 | ScaleOut | |
adjustmentCount | 伸縮組ECS實(shí)例調(diào)整的數(shù)量 | Number | 否 | 0 | |
instancesToBeRemoved | 從伸縮組中移除的ECS實(shí)例 | Json | 否 | {'Type': 'ResourceIds', 'ResourceIds': [], 'RegionId': '{{ ACS::RegionId }}'} | |
clusterId | 集群ID | String | 否 | "" | |
nodepoolId | 節(jié)點(diǎn)池ID | String | 否 | "" | |
desiredSize | 期望節(jié)點(diǎn)數(shù) | Number | 否 | 0 | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | "" |
輸出參數(shù)
參數(shù)名稱 | 描述 | 類型 |
adjustDetail | String | |
lifecycleHookOOSExecutionResult | String |
執(zhí)行此模板需要的權(quán)限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CreateScalingRule",
"ess:DeleteScalingRule",
"ess:DescribeScalingActivities",
"ess:DescribeScalingActivityDetail",
"ess:ExecuteScalingRule",
"ess:RemoveInstances"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:ListExecutions"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"cs:DescribeClusterNodePoolDetail",
"cs:ModifyClusterNodePool"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ESS-AdjustScalingGroupInstanceCount詳情
模板內(nèi)容
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='http://bestwisewords.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">通過創(chuàng)建并執(zhí)行伸縮組規(guī)則來調(diào)整伸縮組的實(shí)例數(shù)。說明:</p>
<ul class="ul">
<li class="li">如果伸縮組已配置期望實(shí)例數(shù),當(dāng)伸縮組內(nèi)實(shí)例數(shù)不等于期望實(shí)例數(shù)時(shí),彈性伸縮服務(wù)會(huì)自動(dòng)進(jìn)行擴(kuò)縮容,確保伸縮組內(nèi)始終保持該數(shù)量的實(shí)例數(shù),執(zhí)行完畢后請(qǐng)到ESS控制臺(tái)查看調(diào)整結(jié)果。</li>
<li class="li">縮容節(jié)點(diǎn)后的集群節(jié)點(diǎn)數(shù)量,不能小于組件最低節(jié)點(diǎn)要求,否則縮容操作可能會(huì)返回 code:IncorrectCapacity 的錯(cuò)誤。</li>
<li class="li">執(zhí)行請(qǐng)確保您的賬號(hào)余額大于新購實(shí)例的費(fèi)用,否則會(huì)返回 code:InvalidAccountStatus.NotEnoughBalance 的錯(cuò)誤。</li>
<li class="li">如果是多可用區(qū)請(qǐng)擴(kuò)容可用區(qū)數(shù)的倍數(shù)。</li>
<li class="li">擴(kuò)容的ECS付費(fèi)方式為按量付費(fèi),如有需要,客戶需要手動(dòng)<a href="http://bestwisewords.com/document_detail/49884.html?spm=5176.2020520101.help.dexternal.6ecb4df5sxWQrt">轉(zhuǎn)包年包月。</a></li>
<li class="li">縮容有兩種方式:縮容指定數(shù)量的ECS(<b>伸縮組ECS實(shí)例調(diào)整的數(shù)量</b>非0)、從伸縮組中移除指定的ECS(<b>伸縮組ECS實(shí)例調(diào)整的數(shù)量</b>為0且選擇要移除的ECS)</li>
<li class="li">縮容數(shù)量不能少于伸縮組內(nèi)最開始開出來的數(shù)量。</li>
</ul>
<p class="p">調(diào)整ACK集群節(jié)點(diǎn)池<a href='http://bestwisewords.com/document_detail/160490.html?spm=5176.2020520152.help.dexternal.253916ddpJbWDl#title-mpp-3jj-oo3'>期望節(jié)點(diǎn)數(shù)</a>。說明:</p>
<ul class="ul">
<li class="li">請(qǐng)仔細(xì)閱讀鏈接文檔并授權(quán)角色AliyunOOSLifecycleHook4CSRole。</li>
</ul>
name-en: Elastic Scaling
name-zh-cn: 彈性擴(kuò)縮容
categories:
- elastic_manage
- application_manage
- computenest
Parameters:
resourceType:
Type: String
Label:
en: ResourceType
zh-cn: 將要調(diào)整的資源類型
AllowedValues:
- ACK
- ESS
Default: ESS
regionId:
Type: String
Label:
en: RegionId
zh-cn: 將要克隆的ECS實(shí)例所在地域
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: 伸縮規(guī)則的調(diào)整方式
AssociationPropertyMetadata:
LocaleKey: ESSGroupAdjustmentType
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ESS
AllowedValues:
- ScaleOut
- ScaleIn
- TotalCapacity
Default: ScaleOut
adjustmentCount:
Type: Number
Label:
en: AdjustmentCount
zh-cn: 伸縮組ECS實(shí)例調(diào)整的數(shù)量
MinValue: 0
MaxValue: 100
Default: 0
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- '${resourceType}'
- ESS
instancesToBeRemoved:
Type: Json
Label:
en: RemovedInstances
zh-cn: 從伸縮組中移除的ECS實(shí)例
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: 節(jié)點(diǎn)池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: 期望節(jié)點(diǎn)數(shù)
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: 根據(jù)資源類型選擇下一個(gè)任務(wù)
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: 根據(jù)伸縮規(guī)則調(diào)整方式選擇下一個(gè)任務(wù)
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實(shí)例
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實(shí)例
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: 創(chuàng)建伸縮規(guī)則
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: 執(zhí)行伸縮規(guī)則
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: 輪詢伸縮活動(dòng)執(zhí)行情況直到成功或者失敗
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: 刪除伸縮組規(guī)則
Action: 'ACS::ExecuteApi'
Properties:
Service: ESS
API: DeleteScalingRule
Parameters:
RegionId: '{{ regionId }}'
ScalingRuleId: '{{ createScalingRule.scalingRuleId }}'
- Name: describeScalingActivityDetail
Description:
en: Describe scaling activity detail
zh-cn: 查詢一個(gè)伸縮活動(dòng)的詳細(xì)信息
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執(zhí)行的輸出
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: 獲取集群節(jié)點(diǎn)池信息
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: 修改集群節(jié)點(diǎn)池配置
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: 等待集群節(jié)點(diǎn)池配置修改完成
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: 調(diào)整方式設(shè)置
en: Scaling Rule Configure Parameters
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: 高級(jí)選項(xiàng)
en: Control Options