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

普段使ってるインフラ構成などについて

 普段使ってるインフラ構成などについて

AWSとかDocker諸々基本的なところから

Ff62f685f43d0a95a1f1dd7b2380306e?s=128

Kazuhiro Tamiwa

February 18, 2018
Tweet

Transcript

  1. 1 ຽྠҰത ීஈ࢖ͬͯΔΠϯϑϥߏ੒ͳͲʹͭ ͍ͯ

  2. 2 ໨࣍ • ࣗݾ঺հ • શମߏ੒ • Docker • CI

    / AWS ECSσϓϩΠ • CloudFormationʹΑΔઃఆ؅ཧ ࣌ؒ଍Γͳ͍ͷͰলུ͠ͳ͕Βɻɻɻ ؒҧͬͨ͜ͱઆ໌ͯͨ͠ΒऴΘ͔ͬͯ Βͬͦ͜Γڭ͍͑ͯͩ͘͞m(_ _)m
  3. 3 ࣗݾ঺հ • ̠ɽ̨ɽϩδϟʔεגࣜձࣾ • ίʔυϨϏϡʔ໺࿠ • ΞϓϦ։ൃ / ΢Σϒ։ൃ

    / ͦͷଞR&D • ࠷ۙΑ͘࢖͏ݴޠ
 PHP/Ruby/Java/Kotlin/Swift etc Ұॹʹ࡞ͬͨਓ→
  4. 4 શମߏ੒

  5. 5 Amazon
 Route 53 Application Load Balancer Auto Scaling group

    web app server web app server Amazon S3 
 bucket CloudFront distribution Amazon
 RDS શମߏ੒ Amazon
 RDS multi-AZ ϝʔϧૹ৴ Τϥʔ؂ࢹ CloudWatch Logs ϩʔΧϧ GitLab Runner GitLab ECS ECR GitLab PhalconPHP(PHP7.x) ϩάղੳ
  6. 6 AWSߏ੒ਤ

  7. 7 Docker

  8. 8 D o c k e r Docker ࣗલͰ։ൃ؀ڥͷ%PDLFSGJMF࡞੒ ࡞੒ͨ͠*NBHFΛ(JU-BC$POUBJOFS3FHJTUSZʹQSJWBUFʹอଘ

    %PDLFS$PNQPTFΛ࡞੒
 ˠ%# "QQMJDBUJPO  3FEJT &MBTUJD4FBSDI4PMS w ։ൃ؀ڥΛॳΊͯࢀՃ͢ΔϦϞʔτͷΤϯδχΞͰ΋3&"%.&͚ͩ Ͱઆ໌ͳ͠ʙ࣌ؒ͘Β͍Ͱߏஙͱ࢖͍ํͷཧղ͕׬ྃ ͦͷ݁Ռ
  9. 9 ։ ൃ ؀ڥ ஈ ֊Ͱ ಘ ΒΕͨ ΋ ͷ

    Docker શһͷ։ൃ؀ڥͷ౷Ұ
 ηοτΞοϓͳͲͷ࣌ؒ୹ॖ
 ςϯϓϨʔτΞϓϦέʔγϣϯΛ࡞੒͢Δ͜ͱͰॳ଎ͷ͋Δ։ൃ
  10. 10 ECSσϓϩΠ

  11. 11 ج ຊ తྲྀ Ε ECSσϓϩΠ GitLab Runner (CI) GitLab

    ECR GitLab Auto Scaling group web app server web app server ECS develop push master push ίϯςφ ΠϝʔδΛ push ίϯςφϦϙδτϦ
  12. 12 Gi t L a b R u nner ECSσϓϩΠ

    $*πʔϧɻϊϦ͸$JSDMF$*΍5SBWJT$*Έ͍ͨͳ͔Μ͡ ઃఆϑΝΠϧ͸ZBNM (JU-BCͷQJQFMJOF͔Β
  13. 13 E C R ECSσϓϩΠ ίϯςφͷΠϝʔδϦϙδτϦ &$3͸&$4ͷϦϙδτϦ͔Β࡞੒

  14. 14 E C S ECSσϓϩΠ λεΫఆٛΛ࡞੒
 ίϯςφͷ৘ใͷઃఆ
 %PDLFSΠϝʔδͷઃఆ$16ϝϞϦFUD 
 ΫϥελʔΛ࡞੒


    &$·ΘΓઃఆ
 &$ΠϯελϯελΠϓ&#4FUD 
 αʔϏεΛઃఆ͢Δ
 ΫϥελʔͰ࣮ߦͯ͠ҡ࣋͢ΔλεΫఆٛΛઃఆ
 &-#ͷઃఆͳͲ
  15. 15 E C S ɿ λ ε Ϋ ECSσϓϩΠ

  16. 16 E C S ɿ Ϋ ϥε λʔ ECSσϓϩΠ

  17. 17 E C S ɿ Ϋ ϥε λʔ ECSσϓϩΠ

  18. 18 E C S ɿ α ʔ Ϗ ε ECSσϓϩΠ

    ←ΊͬͪΌॏཁ
  19. 19 E C S ɿ σ ϓ ϩ Πϝϯτ Φ

    ϓγϣϯ ECSσϓϩΠ λεΫͷ਺: 4 ࠷খϔϧε཰: 50%ɺ࠷େ཰: 100% [ग़ల] https://aws.amazon.com/jp/ blogs/compute/amazon-ecs- launches-new-deployment- capabilities-cloudwatch- metrics-singapore-and- frankfurt-regions/ λεΫͷ਺ʹैͬͯɺߋ৽࣌ʹλεΫఆٛ ͷΠϯελϯεΛΫϥελʔʹ഑ஔ࣮ͯ͠ ߦঢ়ଶʹ͞ΕΔɻ͜ͷͱ͖4×50%=2୆ͣͭ ߋ৽͞ΕΔɹϩʔϦϯάɾσϓϩΠ
  20. 20 E C S ɿ σ ϓ ϩ Πϝϯτ Φ

    ϓγϣϯ ECSσϓϩΠ λεΫͷ਺: 4 ࠷খϔϧε཰: 100%ɺ࠷େ཰: 200% [ग़ల] https://aws.amazon.com/jp/ blogs/compute/amazon-ecs- launches-new-deployment- capabilities-cloudwatch- metrics-singapore-and- frankfurt-regions/ Πϯελϯε͸8୆·Ͱ࢖͑ΔͷͰɺ 4×100%=4୆͕Ұؾʹߋ৽͞ΕΔ
 ϒϧʔάϦʔϯɾσϓϩΠ
  21. 21 E C S ɿ st a g ingͱprod uctio

    n ECSσϓϩΠ TUBHJOH
 ୆ߏ੒Ͱे෼ͳͷͰɺλεΫͷ਺ɺ࠷খϔϧε཰ɺ࠷େ཰ ͰϩʔϦϯάɾσϓϩΠ QSPEVDUJPO
 O୆ߏ੒ͰɺλεΫͷ਺Oɺ࠷খϔϧε཰ɺ࠷େ཰Ͱϩʔ ϦϯάɾσϓϩΠɻαʔϏεεέʔϧͨ͠Β࠷খϔϧε཰ɺ ࠷େ཰ͷϒϧʔάϦʔϯɾσϓϩΠΛ࠾༻ɻ ׬ྃޙ$*͔Β4MBDL΁ ׬ྃ௨஌
  22. 22 ͸ · Γϙ Π ϯτ ECSσϓϩΠ &-#Λ͋ͱ͔ΒઃఆͰ͖ͳ͍ ΞϓϦέʔγϣϯͱ͔Ϛ΢ϯτͯ͠։ൃͯ͠ΔͷͰɺEPDLFSDQ͠ ͳ͍ͱσϓϩΠ͞Εͨίϯςφ্ͰΞϓϦέʔγϣϯͷྶѹ͕ফ͑

    Δ (JU-BC3VOOFS͸ࣗલͷαʔόʔͰ༻ҙ͢ΔͷͰɺຖճϏϧυͷͨ ͼʹJNBHF͕ͨ͘͞Μ૿͑ΔɻσϓϩΠऴΘͬͨΒEPDLFSSNJ͠ͳ ͍ͱϠόΠɻͲ͏ͤ&$3Ͱอଘ͞Ε·͢͠ɻ
  23. 23 Φ ʔ τεέʔϧ ECSσϓϩΠ $MPVE8BUDIͷΞϥʔτϕʔεͰΦʔτεέʔϧͷᮢ஋Λઃఆ Ϋϥελʔͷεέʔϧʹ͔͔Δ࣌ؒɿ෼͘Β͍ &$4αʔϏεͷεέʔϧʹ͔͔Δ࣌ؒɿʙඵ ΫϥελʔεέʔϧΞ΢τɿ$16࢖༻཰Ҏ্ αʔϏεεέʔϧΞ΢τɿ$16࢖༻཰Ҏ্

    ΫϥελʔεέʔϧΠϯɿ$16࢖༻཰ҎԼ αʔϏεεέʔϧΠϯɿ$16࢖༻཰ҎԼ
  24. 24 CloudFormation ࣗಈԽ "84ϦιʔεͷઃఆΛZBNM্ʹఆٛͯ͠؅ཧ͢Δ͜ͱ͕Ͱ͖Δ ˠ"84ͷΠϯϑϥઃఆߏஙΛࣗಈԽ
 ྨࣅαʔϏεɿ5FSSB'PSN w "84ͷߏஙͷςϯϓϨʔτΛ࡞੒͢Δ͜ͱͰΠϯϑϥ·ΘΓͷ޻਺ ͕࡟ݮ w

    ZBNMΛHJU؅ཧ͢Δ͜ͱͰΠϯϑϥߏஙͷมߋΛHJUͰ͓͏͜ͱ͕Ͱ ͖Δ ͦͷ݁Ռ
  25. 25 AWSߏ੒ਤ

  26. 26 CloudFormation ࣗಈԽ ஈ֊ͷZBNMʹ෼͚͍ͯΔ #BTJPO4FSWFS ౿Έ୆αʔόʔ ݉$*ͷߏங
 71$TVCOFUͳͲͷύϥϝʔλઃఆ 4UBHJOH༻ͷ&$43%4ͱύϥϝʔλͷઃఆ 1SPEVDUJPO༻ͷ&$43%4ͱύϥϝʔλͷઃఆ

    ͨͩ͠ɺ"$.ͳͲ͸खಈͷઃఆ͕ඞཁ
  27. 27 ͋Γ͕ͱ͏͍͟͝·ͨ͠ (ɾωɾ)ůŢ