すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:複数ノードの一括削除 (ライフサイクル)

最終更新日:Jan 17, 2025

テンプレート名

ACS-ESS-LifeCycleBulkyDeleteClusterNodes

今すぐ実行

テンプレートの説明

ライフサイクルフックを使用して、Container Service for Kubernetes (ACK) クラスタから一度に複数のノードを削除します。 このテンプレートは、スケールインイベントのみをサポートします。

テンプレートタイプ

自動

所有者

Alibaba Cloud

入力パラメータ

パラメータ

説明

タイプ

必須

デフォルト値

制限

clusterId

クラスタ ID。

String

はい

drainNode

削除するノードからすべてのポッドを削除するかどうかを指定します。

Boolean

はい

releaseNode

Elastic Compute Service (ECS) インスタンスを解放するかどうかを指定します。

Boolean

はい

pageSize

ページサイズ。

String

いいえ

100

essTaskType

Auto Scaling タスクタイプ。

String

いいえ

${essTaskType}

regionId

リージョン ID。

String

いいえ

${regionId}

instanceIds

ECS インスタンスの ID。

List

いいえ

['${instanceIds}']

lifecycleHookId

ライフサイクルフック ID。

String

いいえ

${lifecycleHookId}

lifecycleActionToken

インスタンスに関連付けられている特定のスケーリングアクティビティのトークン。

String

いいえ

${lifecycleActionToken}

OOSAssumeRole

CloudOps Orchestration Service (OOS) によってアシュームされる Resource Access Management (RAM) ロール。

String

いいえ

OOSServiceRole

出力パラメータ

なし

テンプレートを実行するために必要なポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "cs:DeleteClusterNodes",
                "cs:DescribeClusterNodes",
                "cs:DescribeTaskInfo"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ess:CompleteLifecycleAction"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

参照

ACS-ESS-LifeCycleBulkyDeleteClusterNodes

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: Use lifecyclehook to delete cluster nodes (only supports elastic contraction activities)
  zh-cn: 使用生命周期挂钩批量移除CS集群节点(仅支持弹性收缩活动)
  name-en: ACS-ESS-LifeCycleBulkyDeleteClusterNodes
  name-zh-cn: 使用生命周期挂钩批量移除CS集群节点
  categories:
    - elastic_manage
Parameters:
  clusterId:
    Label:
      en: ClusterId
      zh-cn: 集群ID
    Type: String
  drainNode:
    Label:
      en: DrainNode
      zh-cn: 是否自动排空节点上的Pod
    Type: Boolean
  releaseNode:
    Label:
      en: ReleaseNode
      zh-cn: 是否同时移除ECS
    Type: Boolean
  pageSize:
    Label:
      en: PageSize
      zh-cn: 分页大小
    Type: String
    Default: '100'
  essTaskType:
    Label:
      en: EssTaskType
      zh-cn: 弹性伸縮タスクタイプ
    Type: String
    Default: '${essTaskType}'
  regionId:
    Label:
      en: RegionId
      zh-cn: リージョン ID
    Description:
      en: The ID of region
      zh-cn: 'リージョン ID。弾性伸縮システムのデフォルト値 ${regionId} を使用してください。'
    Type: String
    Default: '${regionId}'
  instanceIds:
    Label:
      en: InstanceIds
      zh-cn: ECS インスタンス ID リスト
    Description:
      en: The ID list of the ECS instance
      zh-cn: 'ECS インスタンス ID リスト。弾性伸縮システムのデフォルト値 ["${instanceId}"] を使用してください。'
    Type: List
    Default:
      - '${instanceIds}'
  lifecycleHookId:
    Label:
      en: LifecycleHookId
      zh-cn: ライフサイクルフック ID
    Description:
      en: The ID of the lifecycle hook
      zh-cn: 'ライフサイクルフック ID。弾性伸縮システムのデフォルト値 ${lifecycleHookId} を使用してください。'
    Type: String
    Default: '${lifecycleHookId}'
  lifecycleActionToken:
    Label:
      en: LifecycleActionToken
      zh-cn: インスタンスに関連付けられた特定のスケーリングアクティビティのトークン
    Description:
      en: The token that indicates a specific scaling activity associated with an instance
      zh-cn: 'インスタンスに関連付けられた特定のスケーリングアクティビティを示すトークン。弾性伸縮システムのデフォルト値 ${lifecycleActionToken} を使用してください。'
    Type: String
    Default: '${lifecycleActionToken}'
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS がアシュームする RAM ロール
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: describeClusterNodes
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Gets node names
      zh-cn: ノード名を取得する
    OnError: CompleteLifecycleActionForAbandon
    Properties:
      Service: CS
      API: DescribeClusterNodes
      Method: GET
      Headers:
        Content-Type: application/json
      URI: '/clusters/{{clusterId}}/nodes'
      Parameters:
        pageSize: '{{ pageSize }}'
        instanceIds:
          'Fn::Join':
            - ','
            - '{{ instanceIds }}'
    Outputs:
      nodeNames:
        Type: List
        ValueSelector: '.nodes[].node_name'
  - Name: whetherNodeIsReady
    Action: 'ACS::Choice'
    Description:
      en: Choose next task by nodes
      zh-cn: ノードによって次のタスクを選択する
    Properties:
      DefaultTask: deleteClusterNodes
      Choices:
        - When:
            'Fn::Equals':
              - []
              - '{{ describeClusterNodes.nodeNames }}'
          NextTask: 'CompleteLifecycleActionForContinue'
  - Name: deleteClusterNodes
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Delete the specified nodes of cluster
      zh-cn: クラスタの指定されたノードを削除する
    OnError: CompleteLifecycleActionForAbandon
    Properties:
      Service: CS
      API: DeleteClusterNodes
      Method: POST
      Headers:
        Content-Type: application/json
      URI: '/clusters/{{clusterId}}/nodes'
      Body:
        'Fn::If':
          - 'Fn::Equals':
              - SPOT_REMEDY
              - '{{ essTaskType }}'
          - '{"drain_node": {{ drainNode }}, "release_node": true, "nodes": {{ describeClusterNodes.nodeNames }}, "call_back": true, "is_expired": true}'
          - '{"drain_node": {{ drainNode }}, "release_node": {{ releaseNode }}, "nodes": {{ describeClusterNodes.nodeNames }}, "call_back": true, "is_expired": false}'
    Outputs:
      taskId:
        Type: String
        ValueSelector: '.task_id'
  - Name: untilNodesRemovedSuccessfully
    Action: ACS::WaitFor
    Description:
      en: Wait for the node to be removed successfully
      zh-cn: ノードが正常に削除されるまで待つ
    Retries: 26
    Delay: 30
    OnError: CompleteLifecycleActionForAbandon
    OnSuccess: CompleteLifecycleActionForContinue
    Properties:
      Service: CS
      API: DescribeTaskInfo
      Method: GET
      Headers:
        Content-Type: application/json
      URI: '/tasks/{{deleteClusterNodes.taskId}}'
      Parameters: {}
      DesiredValues:
        - success
      StopRetryValues:
        - fail
      PropertySelector: .state
  - Name: CompleteLifecycleActionForContinue
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Modify lifecycle action for continue
      zh-cn: ライフサイクルアクションを続行に変更する
    OnSuccess: 'ACS::END'
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: CONTINUE
  - Name: CompleteLifecycleActionForAbandon
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Complete lifecycle action for Abandon
      zh-cn: ライフサイクルアクションを破棄に変更する
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: ABANDON