Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ECSの辛いところ

YAMASAKI Masahide
December 19, 2018
2.5k

 ECSの辛いところ

ECSを使ってJob Observerパターンを実践した時の苦労話

YAMASAKI Masahide

December 19, 2018
Tweet

Transcript

  1. ECSとは Amazon Elastic Container Service (Amazon ECS) は、クラスターで Docker コンテ

    ナを簡単に実行、停止、管理できる非常にス ケーラブルで高速なコンテナ管理サービスで す。 https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/Welcome.html
  2. 実装方法詳細 • AutoScaling groupにライフサイクルフックを設定 https://docs.aws.amazon.com/ja_jp/autoscaling/ec2/userguide/lifecycle-hooks.html • DescribeAutoScalingInstances で自インスタンスの LifecycleState が

    "Terminating:Wait" か確認する https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeAutoScalingInstances.html • "Terminating:Wait"の場合は終了処理に入る • CompleteLifecycleAction でパラメータとしてライフサイク ルフック名と "ABANDON" 送る https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CompleteLifecycleAction.html
  3. Auto scaling group のライフサイクルフックの設定はこんな感じ Ec2InstanceAutoScalingGroup: Type: AWS::AutoScaling::AutoScalingGroup Properties: AutoScalingGroupName: !Sub

    ${AWS::StackName} VPCZoneIdentifier: !Ref SubNets LaunchTemplate: LaunchTemplateId: !Ref Ec2InstanceLaunchTemplate Version: !GetAtt Ec2InstanceLaunchTemplate.LatestVersionNumber MinSize: !Ref Ec2AutoscaleMinSize MaxSize: !Ref Ec2AutoscaleMaxSize DesiredCapacity: !Ref Ec2AutoscaleDesiredCapacity LifecycleHookSpecificationList: - LifecycleTransition: autoscaling:EC2_INSTANCE_TERMINATING LifecycleHookName: !Sub ${AWS::StackName}-lc-hook HeartbeatTimeout: 3600 DefaultResult: ABANDON 実装方法詳細