全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-ESS-RollingUpdateByUpdateContainerGroup

更新時間:Sep 06, 2024

模板名稱

ACS-ESS-RollingUpdateByUpdateContainerGroup 通過更新容器組的方式變換伸縮組內的ECI執行個體

立即執行

模板描述

通過更新容器組的方式變換伸縮組內的ECI執行個體

模板類型

自動化

所有者

Alibaba Cloud

輸入參數

參數名稱

描述

類型

是否必填

預設值

約束

invokeType

操作類型

String

scalingGroupId

伸縮組ID

String

containerConfigure

用於更新的容器配置

Json

scalingConfigurationId

伸縮配置ID

String

enterProcess

執行開始要暫停伸縮組流程

List

['ScaleIn', 'ScaleOut', 'HealthCheck', 'AlarmNotification', 'ScheduledAction']

exitProcess

執行結束要恢複的伸縮組流程

List

['ScaleIn', 'ScaleOut', 'HealthCheck', 'AlarmNotification', 'ScheduledAction']

sourceContainerConfigure

用於復原的容器配置

Json

{}

updateType

Containers參數更新方式

String

IncrementalUpdate

sourceExecutionId

用於復原的OOS執行ID

String

""

batchPauseOption

分批模式

String

Automatic

batchNumber

分批執行的批次

Number

5

maxErrors

分批執行的最大錯誤次數

Number

0

OOSAssumeRole

OOS扮演的RAM角色

String

""

輸出參數

執行此模板需要的權限原則

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ess:DescribeScalingInstances",
                "ess:EnterStandby",
                "ess:ExitStandBy",
                "ess:ModifyEciScalingConfiguration",
                "ess:ResumeProcesses",
                "ess:SuspendProcesses"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "eci:DescribeContainerGroups",
                "eci:UpdateContainerGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:ListExecutions"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳情

ACS-ESS-RollingUpdateByUpdateContainerGroup詳情

模板內容

FormatVersion: OOS-2019-06-01
Description:
  en: Rolling update ECI instances in scaling group by update container group
  zh-cn: 通過更新容器組的方式變換伸縮組內的ECI執行個體
  name-en: ACS-ESS-RollingUpdateByUpdateContainerGroup
  name-zh-cn: 通過更新容器組的方式變換伸縮組內的ECI執行個體
  categories:
    - elastic_manage
Parameters:
  invokeType:
    Label:
      en: InvokeType
      zh-cn: 操作類型
    Type: String
    AllowedValues:
      - invoke
      - rollback
  scalingGroupId:
    Label:
      en: ScalingGroupId
      zh-cn: 伸縮組ID
    Type: String
  enterProcess:
    Label:
      en: EnterProcess
      zh-cn: 執行開始要暫停伸縮組流程
    Type: List
    Default:
      - ScaleIn
      - ScaleOut
      - HealthCheck
      - AlarmNotification
      - ScheduledAction
  exitProcess:
    Label:
      en: ExitProcess
      zh-cn: 執行結束要恢複的伸縮組流程
    Type: List
    Default:
      - ScaleIn
      - ScaleOut
      - HealthCheck
      - AlarmNotification
      - ScheduledAction
  containerConfigure:
    Label:
      en: ContainerConfigure
      zh-cn: 用於更新的容器配置
    Type: Json
  sourceContainerConfigure:
    Label:
      en: SourceContainerConfigure
      zh-cn: 用於復原的容器配置
    Type: Json
    Default: {}
  updateType:
    Label:
      en: ContainersUpdateType
      zh-cn: Containers參數更新方式
    Description:
      en: >-
        <ul class="ul">
          <li class="li">RenewUpdate: Full update, all related parameters need to be filled in when updating. If the parameter is a List, it does not support updating an item individually, and if the parameter is a structure, it does not support updating an internal member individually. </li>
          <li class="li">IncrementalUpdate: Incremental update, when updating, you can only fill in a parameter that needs to be updated, and other related parameters remain unchanged. </li>
        </ul>
      zh-cn: >-
        <ul class="ul">          
           <li class="li">RenewUpdate:全量更新,更新時需填寫相關的所有參數。如果參數是一個List,不支援單獨更新某個item,如果參數是一個結構體,不支援單獨更新某個內部成員。</li>
           <li class="li">IncrementalUpdate:累加式更新,更新時可以只填某一需要更新的參數,其它相關參數保持原有不變。</li>
        </ul>
    Type: String
    AllowedValues:
      - RenewUpdate
      - IncrementalUpdate
    Default: IncrementalUpdate
  sourceExecutionId:
    Label:
      en: SourceExecutionId
      zh-cn: 用於復原的OOS執行ID
    Type: String
    Default: ''
  scalingConfigurationId:
    Label:
      en: ScalingConfigurationId
      zh-cn: 伸縮配置ID
    Type: String
  batchPauseOption:
    Label:
      en: BatchPauseOption
      zh-cn: 分批模式
    Type: String
    AllowedValues:
      - Automatic
      - FirstBatchPause
      - EveryBatchPause
    Default: Automatic
  batchNumber:
    Label:
      en: BatchNumber
      zh-cn: 分批執行的批次
    Type: Number
    MinValue: 1
    MaxValue: 100
    Default: 5
  maxErrors:
    Label:
      en: MaxErrors
      zh-cn: 分批執行的最大錯誤次數
    Type: Number
    Default: 0
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: choiceNextTask
    Action: ACS::Choice
    Description:
      en: Choose next task by invoke type
      zh-cn: 根據執行的類型選擇執行的任務
    Properties:
      DefaultTask: getInstance
      Choices:
        - When:
            Fn::Equals:
              - rollback
              - '{{ invokeType }}'
          NextTask: getExecutionInstanceIds
  - Name: getInstance
    Description:
      en: Get the ECI instances
      zh-cn: 擷取ECI執行個體
    Action: ACS::ExecuteApi
    Properties:
      Service: ESS
      API: DescribeScalingInstances
      Parameters:
        ScalingGroupId: '{{ scalingGroupId }}'
        LifecycleState: InService
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: ScalingInstances.ScalingInstance[].InstanceId
  - Name: whetherTheScalingGroupInstanceIsEmpty
    Action: ACS::Choice
    Description:
      en: Check whether the instance in the service in the scaling group is empty
      zh-cn: 檢查伸縮組內服務中的執行個體是否為空白
    Properties:
      DefaultTask: whetherToSuspendProcess
      Choices:
        - When:
            Fn::Equals:
              - []
              - '{{ getInstance.instanceIds }}'
          NextTask: modifyScalingConfigurationForInvoke
  - Name: whetherToSuspendProcess
    Action: ACS::Choice
    Description:
      en: Choose next task by process
      zh-cn: 根據流程值判斷是否暫停流程
    Properties:
      DefaultTask: suspendProcess
      Choices:
        - When:
            Fn::Equals:
              - []
              - '{{ enterProcess }}'
          NextTask: invokeByUpdateContainerGroup
  - Name: suspendProcess
    Action: ACS::ExecuteAPI
    Description:
      en: Suspend process
      zh-cn: 暫停伸縮組流程
    Properties:
      Service: ESS
      API: SuspendProcesses
      Parameters:
        ScalingGroupId: '{{ scalingGroupId }}'
        Process: '{{ enterProcess }}'
  - Name: invokeByUpdateContainerGroup
    Action: ACS::ESS::UpdateContainerGroup
    Description:
      en: Update Container Group
      zh-cn: 更新容器組
    Properties:
      instanceId: '{{ ACS::TaskLoopItem }}'
      scalingGroupId: '{{ scalingGroupId }}'
      containerConfigure: '{{ containerConfigure }}'
      updateType: '{{ updateType }}'
    Loop:
      Items: '{{ getInstance.instanceIds }}'
      BatchPauseOption: '{{ batchPauseOption }}'
      Concurrency:
        Fn::CalculateBatch:
          - '{{ batchNumber }}'
          - '{{ getInstance.instanceIds }}'
  - Name: modifyScalingConfigurationForInvoke
    Action: ACS::ExecuteAPI
    Description:
      en: Modify scaling configuration for invoke
      zh-cn: 更新操作修改伸縮配置
    Properties:
      Service: ESS
      API: ModifyEciScalingConfiguration
      Parameters:
        ScalingConfigurationId: '{{ scalingConfigurationId }}'
        Container: '{{ containerConfigure }}'
        ContainersUpdateType: '{{ updateType }}'
  - Name: whetherToResumeProcessesByGroupInstances
    Action: ACS::Choice
    Description:
      en: Check whether the instance in the service in the scaling group is empty
      zh-cn: 檢查伸縮組內服務中的執行個體是否為空白
    Properties:
      DefaultTask: whetherToResumeProcesses
      Choices:
        - When:
            Fn::Equals:
              - []
              - '{{ getInstance.instanceIds }}'
          NextTask: ACS::END
  - Name: whetherToResumeProcesses
    Action: ACS::Choice
    Description:
      en: Choose next task by process
      zh-cn: 根據流程值判斷是否恢複流程
    Properties:
      DefaultTask: resumeProcesses
      Choices:
        - When:
            Fn::Equals:
              - []
              - '{{ exitProcess }}'
          NextTask: ACS::END
  - Name: resumeProcesses
    Action: ACS::ExecuteAPI
    OnSuccess: ACS::END
    Description:
      en: Resume process
      zh-cn: 恢複伸縮組流程
    Properties:
      Service: ESS
      API: ResumeProcesses
      Parameters:
        ScalingGroupId: '{{ scalingGroupId }}'
        Process: '{{ exitProcess }}'
  - Name: getExecutionInstanceIds
    Action: ACS::ExecuteAPI
    Description:
      en: Get the instance id that has been updated
      zh-cn: 擷取已經更新容器的執行個體ID
    Properties:
      Service: OOS
      API: ListExecutions
      Parameters:
        ParentExecutionId: '{{ sourceExecutionId }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: .Executions[].Parameters.instanceId
  - Name: getRollbackProcess
    Action: ACS::ExecuteAPI
    Description:
      en: Get resource parameters
      zh-cn: 擷取源執行的參數
    Properties:
      Service: OOS
      API: ListExecutions
      Parameters:
        ExecutionId: '{{ sourceExecutionId }}'
    Outputs:
      enterProcess:
        Type: List
        ValueSelector: Executions[].Parameters.enterProcess[]
      exitProcess:
        Type: List
        ValueSelector: Executions[].Parameters.exitProcess[]
  - Name: suspendProcessWithRollBack
    Action: ACS::ExecuteAPI
    Description:
      en: Suspend process
      zh-cn: 暫停伸縮組流程
    Properties:
      Service: ESS
      API: SuspendProcesses
      Parameters:
        ScalingGroupId: '{{ scalingGroupId }}'
        Process: '{{ getRollbackProcess.enterProcess }}'
  - Name: rollbackByUpdateContainerGroup
    Action: ACS::ESS::UpdateContainerGroup
    Description:
      en: Update container group for rollback
      zh-cn: 復原更新容器組
    Properties:
      instanceId: '{{ ACS::TaskLoopItem }}'
      scalingGroupId: '{{ scalingGroupId }}'
      containerConfigure: '{{ sourceContainerConfigure }}'
      updateType: '{{ updateType }}'
    Loop:
      Items: '{{ getExecutionInstanceIds.instanceIds }}'
      BatchPauseOption: '{{ batchPauseOption }}'
      Concurrency:
        Fn::CalculateBatch:
          - '{{ batchNumber }}'
          - '{{ getExecutionInstanceIds.instanceIds }}'
  - Name: modifyScalingConfigurationForRollback
    Action: ACS::ExecuteAPI
    Description:
      en: Modify scaling configuration for rollback
      zh-cn: 復原操作修改伸縮配置
    Properties:
      Service: ESS
      API: ModifyEciScalingConfiguration
      Parameters:
        ScalingConfigurationId: '{{ scalingConfigurationId }}'
        Container: '{{ sourceContainerConfigure }}'
        ContainersUpdateType: '{{ updateType }}'
  - Name: whetherToResumeProcessesWithRollback
    Action: ACS::Choice
    Description:
      en: Choose next task by process
      zh-cn: 根據流程值判斷是否恢複流程
    Properties:
      DefaultTask: resumeProcessesWithRollback
      Choices:
        - When:
            Fn::Equals:
              - []
              - '{{ getRollbackProcess.exitProcess }}'
          NextTask: ACS::END
  - Name: resumeProcessesWithRollback
    Action: ACS::ExecuteAPI
    Description:
      en: Resume process
      zh-cn: 恢複伸縮組流程
    Properties:
      Service: ESS
      API: ResumeProcesses
      Parameters:
        ScalingGroupId: '{{ scalingGroupId }}'
        Process: '{{ getRollbackProcess.exitProcess }}'