ECSのデプロイツールを試している話

E74600a3064ae510f783a9bb8214e8ff?s=47 Yukiyan
September 21, 2016

 ECSのデプロイツールを試している話

2016/09/21 JAWS-UG コンテナ支部 #6 #jawsug_ct
http://jawsug-container.connpass.com/event/37895/

当スライドで引用した資料のリンクを以下に全て置きました。
https://git.io/viHHI

@yukiyan_w
https://twitter.com/yukiyan_w
http://yukiyan.hatenablog.jp/

E74600a3064ae510f783a9bb8214e8ff?s=128

Yukiyan

September 21, 2016
Tweet

Transcript

  1. &$4ͷσϓϩΠπʔϧΛࢼ͍ͯ͠Δ࿩ 2016/09/21 JAWS-UG ίϯςφࢧ෦ #6 #jawsug_ct @yukiyan_w

  2. ʙ4*FS ʙGFFEGPSDF*OD "QQMJDBUJPO&OHJOFFS όονɾ$47ɾ3VCZΛओʹ৮Δɻ Ώ͖΍Μ @yukiyan_w http://yukiyan.hatenablog.jp/ ɾ͜ͳ͍ͩECSͷ࿩Λ͠·ͨ͠ "Replace a

    batch application to ECS // Speaker Deck":http://bit.ly/2d2hfAL
  3. ౰εϥΠυͰҾ༻ͨ͠ࢿྉͷϦϯΫΛ ҎԼʹશͯஔ͖·ͨ͠ IUUQTHJUJPWJ))*

  4. &$4ͷσϓϩΠπʔϧ͍ͬͺ͍͋Δ

  5. None
  6. ๻ͷνʔϜ͸ʜ

  7. ΦϨΦϨ3BLFUBTLΛ࢖͍ͬͯΔ

  8. ɾ࡞ऀ͔͠ղಡͰ͖ͳ͍໰୊ ϝϯς͖͍ͭ  ɾಾͷZNM໰୊ EPDLFSDPNQPTFMJLFʹॻ͖͍ͨ

  9. &$4ͷσϓϩΠπʔϧΛௐࠪͯ͠ΈΔ

  10. ɾ ɾaws official ɾcompose likeͳymlͰtaskΛొ࿥Ͱ͖Δ ɾservice΋ొ࿥Ͱ͖Δ͕ELBͱͷඥ෇͚͸Ͱ͖ͳ͍ ɾ"Create services with a

    load balancer · Issue #21 · aws/amazon-ecs-cli":https://git.io/viSkK
  11. ɾ ɾcompose likeͳymlͰtaskΛొ࿥Ͱ͖Δ ɾservice΋ొ࿥Մೳ(CLBͱͷඥ෇͚΋ɻALB͸·ͩɻ) ɾσϓϩΠ͸ECSΫϥελΛ੾Γସ͑ΔλΠϓ(bluegreen) ɾ"EC2 Container Service(ECS)Λ؅ཧͯ͠ɺBlue-Green DeploymentΛ࣮ݱ͢ΔπʔϧΛॻ͍ͨ -

    tehepero note(ɾ Т<)”:http://bit.ly/2d1Mqfq ɾ"Amazon EC2 Container Service(ECS)ͱٔΕͨ1೥ͱίϯςφܳਓͷདྷ೥ʹ͍ͭͯ - tehepero note(ɾТ<)”:http:// bit.ly/2cOsGZi ɾ"Flexible Blue Green DeploymentͷεεϝʛαΠόʔΤʔδΣϯτ ެࣜΤϯδχΞϒϩά":http://amba.to/2ddJx7F
  12. ɾShell ɾserviceͷσϓϩΠʹಛԽ ɾDockerfile͕͋ΔͷͰίϯςφܦ༝Ͱ࣮ߦՄೳ ɾ"AWS Application Load Balancer + Amazon ECS

    ͰDockerͷϗοτσϓϩΠ؀ڥΛߏஙͨ͠ - Glide Note":http://bit.ly/2d1QAUn
  13. ɾ"ECS Λར༻ͨ͠ΦϑϥΠϯδϣϒͷ࣮ߦ؀ڥ - ΫοΫύου։ൃऀϒϩά”:http://bit.ly/2d1TfgR ɾ"Scalable Job Queue System Built with

    Docker // Speaker Deck”:http://bit.ly/2d1TsAI ɾ"hako͕ALBʹରԠͨ͠ͷͰ࢖ͬͯΈͨ - so what”:http://bit.ly/2d1TSao ɾ"hakoͷoneshotΛ࢖͏ - so what":http://bit.ly/2d1Tmcf ɾ ɾtask͕ొ࿥Մೳ(ͨͩ͠compose likeͳymlͰ͸ͳ͍) ɾservice͕ొ࿥Մೳ(CLB΍ALBͱͷඥ෇͚΋Մೳ)
  14. ૉৼΓͯ͠ΈΔ

  15. !͓࿳ͼ! IBLPʹ͍ͭͯ͸࢖͍ํͷ೺Ѳ͕ؒʹ߹Θͳ͔ͬͨɻ ίʔυಡΈ్தʜ

  16. ECS Cluster EC2 ECS Cluster Internal CLB EC2 EC2 ALB

    24224 24224 Dynamic Port 80 log-container.fluentd:24224 /index.html ૉৼΓͷߏ੒ public subnet private subnet
  17. &$4Ͱͳʹ͔ͭ͘Δͱ͖ͷجຊతͳྲྀΕ

  18.  -BVODIDPOpH  "VUPTDBMJOHHSPVQ  &-#  5BTLEFpOJUJPO  5BTLTFSWJDF

     ;FSP%PXOUJNF%FQMPZNFOUT
  19. ֤ϑΣʔζͰFDTDMJ FDTGPSNBUJPO FDTEFQMPZΛ ࢖ͬͯΈΔ

  20.  -BVODIDPOpH  "VUPTDBMJOHHSPVQ  &-#  5BTLEFpOJUJPO  5BTLTFSWJDF

     ;FSP%PXOUJNF%FQMPZNFOUT
  21. ecs-cli up \ --verbose \ --keypair "yukiyan" \ --capability-iam \

    --size 1 \ --vpc "vpc-1234" \ --subnets "subnet-1234","subnet-1234" \ --security-group "sg-1234" \ --image-id "ami-12345" \ --instance-type "t2.micro"
  22. FDTDMJVQʹΑͬͯ$MPVE'PSNBUJPO͕ؤுΔਤ

  23.  -BVODIDPOpH  "VUPTDBMJOHHSPVQ  &-#  5BTLEFpOJUJPO  5BTLTFSWJDF

     ;FSP%PXOUJNF%FQMPZNFOUT
  24. &-#ͷ࡞੒͸ɺ ɾBXTίϚϯυ ɾ5FSSBGPSN ౳Λ࢖ͬͯؤுΔ IBLPͩͱ࡞ͬͯ͘ΕΔؾ͕͢Δ ཁௐࠪ ɻ ɾ"hako/hello-lb-v2.yml · eagletmt/hako":https://git.io/viS1Z

  25.  -BVODIDPOpH  "VUPTDBMJOHHSPVQ  &-#  5BTLEFpOJUJPO  5BTLTFSWJDF

     ;FSP%PXOUJNF%FQMPZNFOUT
  26. UBTLBQQZNM

  27. UBTLqVFOUEZNM

  28. $ ecs-formation task plan ← Dry run $ ecs-formation task

    apply
  29.  -BVODIDPOpH  "VUPTDBMJOHHSPVQ  &-#  5BTLEFpOJUJPO  5BTLTFSWJDF

     ;FSP%PXOUJNF%FQMPZNFOUT
  30. qVFOUETFSWJDFͷ্ཱͪ͛ͱJOUFSOBM$-#ͱͷؔ࿈෇͚

  31. TFSWJDFDMVTUFSOBNFZNM

  32. $ ecs-formation service plan ← Dry run $ ecs-formation service

    apply
  33. BQQTFSWJDFͷ্ཱͪ͛ͱ"-#ͱͷؔ࿈෇͚

  34. KTPOॻ͍ͯɺBXTίϚϯυͰؤுΔ FDTGPSNBUJPO͸"-#ະରԠ͕ͩɺ ผϒϥϯνͰ։ൃͯ͠Δงғؾ͸͋ͬͨɻ IBLPͩͱରԠࡁΈ ཁௐࠪ ɻ ɾ"BlueGreen Deployment for ALB

    by stormcat24 · Pull Request #98 · stormcat24/ecs- formation”:https://git.io/viSXF ɾ"hako͕ALBʹରԠͨ͠ͷͰ࢖ͬͯΈͨ - so what”:http://bit.ly/2d1TSao BQQTFSWJDFͷ্ཱͪ͛ͱ"-#ͱͷؔ࿈෇͚
  35.  -BVODIDPOpH  "VUPTDBMJOHHSPVQ  &-#  5BTLEFpOJUJPO  5BTLTFSWJDF

     ;FSP%PXOUJNF%FQMPZNFOUT
  36. ecs-deploy \ -c yukiyan-cluster \ -n app \ -i yukiyan/app:latest

    \ -D 1 \ # desired count -m 100 \ # minumumHealthyPercent -M 200 # maximumPercent
  37. ॴײ

  38. ɾFDTDMJVQͷμΠφϛοΫ͞ʹڻ͘ ɾFDTGPSNBUJPO͸QMBOͱ͔͋Δ͠ɺ৭͕ͭ͘͠ɺ݁ߏ޷͖ ŠūŶŜƃ  ɾFDTEFQMPZ͸σϓϩΠ׬ྃ·Ͱ଴ͬͯ͘Εͯྑ͍ ɾ࢖͏πʔϧ͸̍ͭʹߜΓ͍ͨɻࣗ෼Ͱ࡞Δ͔13౤͛Δ͔ʜ ɾIBLPௐ΂ΔͧʂϦϑΝϨϯε ৄ͍͠3&"%.& ཉ͍͠ʜ ɾશͯ044ͳͷͰɺཉ͍͠ػೳ͸13Λग़͠·͠ΐ͏

    ࣗռ
  39. ɾFDTDMJVQͷμΠφϛοΫ͞ʹڻ͘ ɾFDTGPSNBUJPO͸QMBOͱ͔͋Δ͠ɺ৭͕ͭ͘͠ɺ݁ߏ޷͖ ŠūŶŜƃ  ɾFDTEFQMPZ͸σϓϩΠ׬ྃ·Ͱ଴ͬͯ͘Εͯྑ͍ ɾ࢖͏πʔϧ͸̍ͭʹߜΓ͍ͨɻࣗ෼Ͱ࡞Δ͔13౤͛Δ͔ʜ ɾIBLPௐ΂ΔͧʂϦϑΝϨϯε ৄ͍͠3&"%.& ཉ͍͠ʜ ɾશͯ044ͳͷͰɺཉ͍͠ػೳ͸13Λग़͠·͠ΐ͏

    ࣗռ ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠