ECS サービスのデプロイ可用性設定の確認

ECS のデプロイ時に必要な正常タスク数と余剰容量を併せて確認してください。

説明

ローリングデプロイでは、稼働を続ける正常なタスクの数と、新しいタスクを配置する余裕を決めます。deployment_configuration を省略するとサービスの既定値が適用されます。

想定される影響

正常なタスクが減ると処理が中断する場合があります。また、配置条件に合うインスタンスに空きがなければ更新が進みません。

対処方法

desired_count に minimum_healthy_percent と maximum_percent を掛け、更新中のタスク数の範囲を求めます。配置条件を満たすインスタンスの空き容量を確認し、デプロイ中のタスクの正常性を確かめてください。

例

どちらも同じ EC2 レプリカサービスにタスクを 3 個要求します。指定したクラスター、タスク定義、flavor==test の条件を満たすインスタンスが必要です。

変更前

yaml
- name: ECS 서비스 생성
  community.aws.ecs_service:
    state: present
    name: test-service
    cluster: test-cluster
    task_definition: test-task-definition
    desired_count: 3
    placement_constraints:
      - type: memberOf
        expression: "attribute:flavor==test"
    placement_strategy:
      - type: binpack
        field: memory

変更後

yaml
- name: ECS 서비스 생성
  community.aws.ecs_service:
    state: present
    name: test-service
    cluster: test-cluster
    task_definition: test-task-definition
    desired_count: 3
    deployment_configuration:
      minimum_healthy_percent: 75
      maximum_percent: 150
    placement_constraints:
      - type: memberOf
        expression: "attribute:flavor==test"
    placement_strategy:
      - type: binpack
        field: memory

最小値の 75% は切り上げて 3 個、最大値の 150% は切り捨てて 4 個です。既存の 3 個を稼働させたまま入れ替えを始めるには、追加の 1 個を配置できる容量が必要です。

参考資料