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

Webサービスを1日10回デプロイするための取り組み / SRE NEXT 2020

Webサービスを1日10回デプロイするための取り組み / SRE NEXT 2020

FUJIWARA Shunichiro

January 25, 2020
Tweet

More Decks by FUJIWARA Shunichiro

Other Decks in Technology

Transcript

  1. 8FC؟٦ؽأ׾傈㔐
    رفٗ؎ׅ׷׋׭ך《׶穈׫
    43&/&95
    !GVKJXBSB

    View full-size slide

  2. !GVKJXBSB
    43&ث٦ي
    HJUIVCDPNGVKJXBSB
    TGVKJXBSBIBUFOBCMPHDPN
    WEB+DB Press vol.111ʙ SREνʔϜ࿈ࡌ
    ΈΜͳͷGoݴޠ

    View full-size slide

  3. (BNF$PNNVOJUZ

    View full-size slide

  4. "HFOEB
    • σϓϩΠͷߏ੒ཁૉͱߴ଎Խͷྺ࢙
    1. CI
    2. ഑෍
    3. Τϥʔݕ஌
    4. ϩʔϧόοΫ
    • ͩΕͰ΋σϓϩΠͰ͖Δ࢓૊Έͱ؅ཧ
    • ίϯςφҠߦޙͷσϓϩΠ

    View full-size slide

  5. ⟗꟦ְָ׷ה؜٦يָ׮׏ה꬗涯ֻז׷
    ιʔγϟϧήʔϜϢʔβʔ޲͚ͷίϛϡχςΟαʔϏε
    άϧʔϓνϟοτɺϘΠενϟοτɺ഑৴ػೳͳͲΛఏڙ

    View full-size slide

  6. -PCJךءأذيך娖〷
    2010೥ ʮφΧϚοϓʯͱͯ͠ϦϦʔε (AWS us-east-1)
    2011೥ ΦϯϓϨ؀ڥ΁Ҡߦ
    2013೥ ʮLobiʯʹվ໊ɺAWS (ap-northeast-1) ʹҠߦ
    2019೥ EC2 → ECS Ҡߦ։࢝ (ਐߦத)
    ΋͏͙͢10೥બख
    30ʙ40ਓͷνʔϜɺΤϯδχΞ͕൒਺ఔ౓
    SRE 2໊(݉೚)

    View full-size slide

  7. -PCJךءأذي圓䧭
    • APIαʔό Perl on EC2
    • ϚΠΫϩαʔϏεతͳ΋ͷ Go (͔ͭͯ͸Nodeɺ࠷ۙશഇʹ੒ޭ)
    • σʔλετΞ
    MySQL (on EC2... ΋͏͙͢ Aurora ʹͳΔ༧ఆ)
    Redis (ElastiCache)
    • ϒϥ΢β޲͚ϑϩϯτΤϯυ Nuxt.js (Vue.js)
    (͔ͭͯ͸ Angular.JS 1.x ࡢ೥ Nuxt ʹҠߦ)
    • iOS, Android ޲͚ωΠςΟϒΞϓϦ

    View full-size slide

  8. 傈ח㔐رفٗ؎׃׋ְ
    ͜͜Ͱ͍͏σϓϩΠ = ҎԼͷ͢΂ͯ
    • αʔόΞϓϦέʔγϣϯ (ຊମAPIɺϚΠΫϩαʔϏε)
    • ϑϩϯτΤϯυ (Nuxt.JS)
    • EC2 ͷϓϩϏδϣχϯά (Chef)
    • AWSͷߏ੒มߋ (Terraform)
    मਖ਼΍ػೳ௥Ճɺ࡟আ͸͙͢ʹσϓϩΠ͍ͨ͠
    Ұ౓ͷࠩ෼Λখࣦͯ͘͞͠ഊΛڐͤΔΑ͏ʹɾӨڹൣғΛݶఆ
    ৗʹσϓϩΠ͍ͯ͠Ε͹ɺرفٗ؎ָ䙳ֻזֻז׷

    View full-size slide

  9. 傈ח⡦儗꟦⢪ִ׷ַ
    Ӧۀ࣌ؒ 9:29ʙ18:29 (9࣌ؒ)
    Ӧۀ࣌ؒ֎ɺٳલ೔(ޕޙ)͸جຊతʹσϓϩΠ͠ͳ͍
    ٳલ೔ʹσϓϩΠ͢Δͱͦͷ࣌఺Ͱ͸໰୊͕ͳͯ͘΋…
    → ͦͷ໷ͷϐʔΫλΠϜʹ໰୊͕ൃ֮
    → ࣍ͷ໷ؒɾૣேͷόονॲཧʹ໰୊͕ൃੜ
    → Ϣʔβʔͷ໰͍߹Θ͕ͤٳ೔தʹ૿͑Δ
    ͲΕ΋ٳ೔ରԠ͕ඞཁʹͳΔ
    սٕ٦ٕվͲ͏ͯ͠΋ٳલ೔ʹσϓϩΠ͍ͨ͠৔߹͸
    ରԠͰ͖ΔਓһΛࣄલ֬อ͢Δ(ٳ೔ग़ۈͯ͠΋Β͏)

    View full-size slide

  10. 儗꟦ד㔐رفٗ؎ׅ׷׋׭חכ
    1ճͷσϓϩΠʹ࢖͑Δ࣌ؒ͸30෼ҎԼ
    ߴස౓ʹσϓϩΠ͢ΔͨΊʹ
    → 1ճ1ճͷσϓϩΠΛߴ଎Խ͢Δ
    ୭Ͱ΋σϓϩΠͰ͖ΔΑ͏ʹ
    → ઐ೚ͷ୲౰ऀΛ࡞Βͳ͍
    ͍ͭԿ͕σϓϩΠ͞Ε͔ͨ؅ཧͰ͖ΔΑ͏ʹ
    → ࣗಈͰه࿥ɺՄࢹԽ͢Δ

    View full-size slide

  11. չرفٗ؎պך銲稆
    1. CI → ςετ͕௨͍ͬͯͳ͍΋ͷ͸ϦϦʔεͰ͖ͳ͍
    2. Ϗϧυ/഑෍ (ڱٛͷσϓϩΠ)
    3. Τϥʔݕ஌ → ໰୊͸͙͢ʹݕ஌͍ͨ͠
    4. ϩʔϧόοΫ → ଈ࠲ʹ໭ͯ͠μϝʔδΛ࠷খݶʹ
    ͜ΕΒׅץגך銲稆׾넝鸞⻉͍ͯ͘͠

    View full-size slide

  12. رفٗ؎넝鸞⻉ך娖〷$*箟
    1. $*
    2. ഑෍
    3. Τϥʔݕ஌
    4. ϩʔϧόοΫ

    View full-size slide

  13. $*넝鸞⻉ך娖〷
    ຊମ API = Perl ͷΘΓͱେ͖͍ϞϊϦε
    ΞϓϦέʔγϣϯ 26ສߦ ʴ ςετ 26ສߦ
    (Cookpad ຊମͷRuby͕27ສߦ1 ϥΠϒυΞϒϩάͷίʔυ͕41ສߦ2)
    ࣮ࡍʹ MySQL ΍ Redis Λىಈͯ͠ςετ͍ͯ͠Δ
    ςετΛ۪௚ʹ΍Δͱ΋ͷֻ͍͕͔࣌ؒ͢͝Δ
    ۩ମతʹ͸Կ΋ߟ͑ͣ௚ྻʹ΍Δͱ೔͕฻ΕΔϨϕϧ
    2 https://logmi.jp/tech/articles/322235
    1 https://employment.en-japan.com/engineerhub/entry/2019/09/17/103000

    View full-size slide

  14. $*넝鸞⻉ך娖〷
    Jenkins master + slave (ڧ͍EC2Πϯελϯε)
    Perl ͷςετ͸جຊతʹγϯάϧϓϩηε
    ίΞ͕͍ͭ͋ͬͯ͘΋ͦͷ··Ͱ͸଎͘ͳΒͳ͍ͨΊࣗલͰฒྻԽ
    MySQL / Redis / etc ΋ฒྻͰىಈ͠ͳ͍ͱεέʔϧ͠ͳ͍
    (͕ɺίΞ਺෼ىಈ͢Δͷ͸ແཧ)
    1ϓϩηεͷ MySQL Λ8ϓϩηεͷ Perl Ͱར༻͢Δ = 1ηοτ
    ͦΕΛ͞Βʹ8ฒྻͰಈ͔͢ = ߹ܭ64ฒྻ
    64ίΞϚγϯͰ10෼͙Β͍ͰऴΘΔঢ়ଶͰ͸͋ͬͨ

    View full-size slide

  15. $*ָ鹼ְֿהח״׷أزٖأ
    push ͯ͠΋୭͔͕ςετΛճ͍ͯ͠Δͱ10෼Ҏ্଴ͭ
    ෳ਺଴͕ͪ͋Δͱ਺े෼
    ϩʔΧϧͰͦͷςετ͚ͩճͨ͠Γ͍ͯ྇͠Ͱ͍͕ͨ
    pushͯ͠ΈͨΒϩʔΧϧͰճ͍ͯ͠ͳ͍ςετ͕ίέͨΓ͢Δ
    ࠷ऴతʹ͸͢΂ͯ௨͔ͯ͠ΒσϓϩΠ͢Δඞཁ͕͋Δ
    ۓٸରԠ࣌ʹ΋Ͳ͔͍͠

    View full-size slide

  16. $JSDMF$*ְְָ׵׃ְ׊
    CircleCI Performance Plan (౰࣌) ͷମݧ͕Α͍ͱ͍͏࿩Λฉ͍ͨͷͰಋೖ
    2019೥5݄ʙ
    ࠷େ8ίΞ (౰࣌) ͷίϯςφΛฒྻͰىಈͰ͖Δ
    ىಈ͍ͯ͠Δίϯςφ਺ × ࣌ؒͰར༻ྉ͕ܾ·Δ (+ΞΫςΟϒϢʔβʔ՝ۚ)

    View full-size slide

  17. $JSDMF$*חذأز׾䭯׏גְֻ
    8ίΞίϯςφΛ20ฒྻ × 1ίϯςφ಺Ͱ8ฒྻ = 160ฒྻ
    10෼ → 3෼ʹʂ

    View full-size slide

  18. $*ך넝鸞⻉٥أ؛٦ٓؽٔذ؍ך栻䖤
    1. ίʔυͱςετΛॻ͘
    2. commit & push
    3. GitHub Ͱ PR Λ࡞ͬͯઆ໌Λॻ͍͍ͯΔ͏ͪʹ…
    4. CI ͕ऴΘ͍ͬͯΔ
    ετϨε͕ͳ͍
    ࠓޙςετ͕૿͑ͯ΋ฒྻ਺Λ্͛ͯεέʔϧͰ͖Δ

    View full-size slide

  19. UJQT$JSDMF$*ךذأز؎ً٦آꂁ縧㜥䨽
    Lobi ͷαʔό͸͢΂ͯ AWS ౦ژϦʔδϣϯ (ap-northeast-1) ʹ͋Δ
    Կ΋ߟ͑ͣʹ ECR (ίϯςφϨδετϦ) ΋౦ژϦʔδϣϯΛ࢖͍͕ͬͯͨ
    CircleCI ͷ࣮ߦ؀ڥ͸ us-east-1 ʹ͋Δ (ݱ࣌఺)
    → CI ࣮ߦ͝ͱʹόʔδχΞ͔Β౦ژͷίϯςφΠϝʔδΛ Pull (×ฒྻ਺)

    View full-size slide

  20. $JSDMF$*ךذأز欽؎ً٦آכVTFBTUח縧ֻ
    ౦ژʹ͋Δͱ͍Ζ͍Ζίετ͕ߴ͍
    • ίϯςφͷىಈ࣌ؒ

    • Ϧʔδϣϯؒసૹྉۚ
    "
    ͜Ε͚ͩͰίϯςφىಈ͕ߴ଎ʹ

    View full-size slide

  21. رفٗ؎넝鸞⻉ך娖〷ꂁ䋒箟
    1. CI
    2. ꂁ䋒
    3. Τϥʔݕ஌
    4. ϩʔϧόοΫ

    View full-size slide

  22. ؿ؋؎ٕꂁ䋒넝鸞⻉ך娖〷
    2010೥ʙ σϓϩΠαʔό(EC2) ͔Β֤ϗετ͕ git pull
    • ୆਺͕૿Ճ͢Δͱ Git ͷෛՙ͕όΧʹͳΒͳ͍
    • όΠφϦͷ੒Ռ෺Λ commit ͨ͘͠ͳ͍
    2013೥ʙ σϓϩΠαʔό͔Β֤ϗετʹฒྻ rsync (push)
    • AWSʹҠߦͯ͠ϗετ୆਺΋૿Ճɺ਺े୆ʹσϓϩΠ͕ඞཁʹ
    • 10ฒྻͰ rsync ͯ͠΋ऴΘΔ·Ͱ3ʙ4෼(Ջ)

    View full-size slide

  23. ؔ٦زأ؛٦ٕפך㼎䘔
    2014೥ήʔϜಈը࿥ըαʔϏεΛSDKఏڙ։࢝(ݱࡏ͸ऴྃ)
    ࠷ॳ͸ Elastic Transcoder Λར༻
    ϞϯελʔετϥΠΫʹಋೖ
    → Elastic Transcoder Ͱ͸嫣剢㹺ָ䒉אꆃ겘ח
    ΠϯελϯεΛେྔʹىಈͯࣗ͠લͰಈըม׵͢Δ࡞ઓʹมߋ
    → ؔ٦زأ؛٦ٕ׃׋ְ (੾࣮)
    ͋Δϗετ͔ΒϑΝΠϧΛ഑ΔઓུͰ͸Φʔτεέʔϧ΁ͷରԠ͕ࠔ೉
    AMI Λຖճ࡞͍ͬͯͨΒ1೔ʹ10ճσϓϩΠͰ͖ͳ͍

    View full-size slide

  24. 4USFUDIFS׾Ꟛ涪
    HJUIVCDPNGVKJXBSBTUSFUDIFS
    ഑෍Λ push → pull ʹ
    σϓϩΠͷ഑෍෺ (tar.gz)Λ͋Β͔͡Ί S3 ʹஔ͘
    ֤ϗετͷ Stretcher(ίϚϯυ) ͕ S3 ͔Β औಘɺ
    ల։ɺϓϩηε࠶ىಈΛߦ͏
    ΦʔτεέʔϧͰىಈͨ͠ϗετ͸࠷৽ͷtarΛS3
    ͔Βऔಘͯ͠ΞϓϦέʔγϣϯΛىಈ͢Δ
    ࢥ૝తʹ͸ίϯςφͷσϓϩΠͱࣅͨΑ͏ͳ΋ͷ
    ίϯςφ࣮ӡ༻͸·ͩૣ͍(2014೥຤)
    ͔͠͠Φʔτεέʔϧ΁ͷରԠ͸ࠓ͙͍ͨ͢͠
    ં஭Ҋ

    View full-size slide

  25. 4USFUDIFSח״׷넝鸞⻉⸬卓
    • rsync ࣌୅ 3ʙ4෼
    • tar࡞੒ / S3 ΁Ξοϓϩʔυ 30ඵ
    • શ୆ʹΠϕϯτ௨஌ͯ͠ Stretcher ͕σϓϩΠΛ׬ྃ͢Δ·Ͱ 30ඵ
    ߹ܭ1෼ఔ౓ʹ୹ॖ
    1෼ͳΒͦͷ··଴ͯΔ
    3ʙ4෼Ջͩͱͦͷؒʹଞͷ͜ͱΛͨ͘͠ͳΔ

    View full-size slide

  26. 4USFUDIFSח״׷أ؛٦ٓؽٔذ؍ך栻䖤
    rsync: ഑෍ݩͷϗετͷ CPU / ωοτϫʔΫͰ཯଎
    ୆਺͕૿͑ΔͱΠϯελϯεΛڧ͘͢Δඞཁ͕͋Δ
    Stretcher: S3 ͷڧ͞ʹґଘ
    S3 ͕଱͑ͯ͘ΕΔݶΓεέʔϧ͢Δ

    View full-size slide

  27. رفٗ؎넝鸞⻉ך娖〷ؒٓ٦嗚濼箟
    1. CI
    2. ഑෍
    3. ؒٓ٦嗚濼
    4. ϩʔϧόοΫ

    View full-size slide

  28. ؒٓ٦嗚濼ךꅾ銲䚍
    σϓϩΠޙɺΤϥʔ͕ͳ͍͜ͱΛ֬ೝ͔ͯ͠ΒͰͳ͍ͱ׬ྃͰ͖ͳ͍
    ൃ֮લʹผͷσϓϩΠΛߦͬͯ͠·͏ͱϩʔϧόοΫ͕൥ࡶʹͳΔ
    ϩά͔Β໰୊͕ൃੜͨ͠৔߹ʹߴ଎ʹݕ஌ͯ͠௨஌͢Δ࢓૊ΈΛ੔͑Δ
    1෼ఔ౓Ͱݕ஌͍ͨ͠

    View full-size slide

  29. /PSJLSBח״׷ؚٗפךؙؒٔ
    norikra.github.io Stream processing with SQL for everybody
    ετϦʔϛϯάσʔλʹରͯ͠SQLͰΫΤϦΛ࣮ߦͰ͖Δ
    αʔό → Fluentd → Norikra → ௨஌

    View full-size slide

  30. ،فٔ؛٦ءّٝךַؚٗ׵ז׿׵ַךؒٓ٦׾嗚濼
    app_exception count:1 app-i-0ad5e77d [613][667331357105553408]
    [WARN]error: Can't call method "as_json_for_invitation" on an undefined value ...
    SELECT 'app_exception' AS title,
    count(*) AS count,
    last(_hostname) AS _hostname,
    last(message) AS message
    FROM app.win:time_batch(1 min)
    WHERE
    (message LIKE '%Caught exception%'
    OR message LIKE '%error:%'
    OR message LIKE '%limit exceeded:%')
    AND (message NOT LIKE '%[INFO]%')
    ͜ͷΫΤϦͰϚον͢Δͱ1෼ʹ1౓௨஌͕དྷΔ

    View full-size slide

  31. ؚٗ嗚濼׾黝ⴖזXJOEPXד㹋遤ׅ׷
    Τϥʔ͕େྔൃੜͯ͠΋1෼ʹ1ճ͚ͩ௨஌͢Δ
    (௨஌Λരൃͤ͞ͳ͍)
    • Τϥʔͷൃੜ਺
    • ൃੜͨ͠ϗετ
    • ۩ମతͳϝοηʔδ
    Λ௨஌ʹࡌͤͯɺৄࡉʹݟΔ͔Ͳ͏͔Λ൑அ͢Δ
    ϩάू໿ͱݕ஌ΛετϦʔϛϯάͰߦ͍ɺΠϕϯτൃੜޙ1෼Ͱ௨஌͕དྷΔΑ͏ʹ

    View full-size slide

  32. رفٗ؎넝鸞⻉ך娖〷ٗ٦ٕغحؙ箟
    1. CI
    2. ഑෍
    3. Τϥʔݕ஌
    4. ٗ٦ٕغحؙ

    View full-size slide

  33. ٗ٦ٕغحؙ
    σϓϩΠͯ͠໰୊͕ൃ֮ͨ͠Βଈ࠲ʹ໭͍ͨ͠
    稆劰זٗ٦ٕغحؙرفٗ؎׾׮ֲ㔐
    1. ϦόʔτPR࡞੒ɺϨϏϡʔ
    ؒҧͬͨίϛοτΛϦόʔτ͍ͯ͠ͳ͍͔
    2. ϦϦʔεϒϥϯνʹϚʔδ
    CI΋଴͍ͪͨ
    3. σϓϩΠ͠௚͠
    Ͳ͏ٸ͍Ͱ΋5෼Ҏ্ֻ͔Δ
    PRΛϦόʔτ͢Δͷ͸ਓؒͳͷͰϛε͕ࠞೖ͢Δ༨஍͕͋Δ

    View full-size slide

  34. 4USFUDIFSח״׷넝鸞ٗ٦ٕغحؙ
    pullܕσϓϩΠ = ࠓճͷσϓϩΠ௚લ·ͰσϓϩΠ͞Ε͍ͯͨ੒Ռ෺͸S3ʹ͋Δ
    σϓϩΠ࣌ʹࣗಈͰ௚લͷ੒Ռ෺ͷURLΛه࿥
    ϩʔϧόοΫ = ௚લͷURLΛࢦఆ࣮ͯ͠ߦ͢Δ͚ͩ
    • tar࡞੒/S3 upload 30ඵ
    • શ୆ʹΠϕϯτ௨஌ͯ͠ Stretcher ͕σϓϩΠΛ׬ྃ͢Δ·Ͱ 30ඵ
    30ඵͰϩʔϧόοΫ͕׬ྃ
    ਓ͕ؒհࡏ͠ͳ͍ͷͰϛεΛ͠ͳ͍

    View full-size slide

  35. رفٗ؎넝鸞⻉תה׭
    1. CI: Jenkins ࣌୅ 10෼ → $JSDMF$*ⴓ
    2. ഑෍: rsync ࣌୅ 3ʙ4෼ → 4USFUDIFSⴓ
    3. Τϥʔݕ஌: /PSJLSBⴓ
    4. ϩʔϧόοΫ: ϦόʔτPR 5෼ → 4USFUDIFS猱
    ຖճͷσϓϩΠΛ5෼ఔ౓Ͱ׬ྃͰ͖ΔΑ͏ʹͳͬͨ

    View full-size slide

  36. 铩ד׮رفٗ؎דֹ׷➬穈׫ה盖椚

    View full-size slide

  37. 铩ד׮رفٗ؎דֹ׷➬穈׫ה盖椚
    رفٗ؎ך孖⚺⻉
    ❌ ಛఆͷ୲౰ऀ͕σϓϩΠ

    ίʔυΛॻ͍ͨਓ͕ͩΕͰ΋σϓϩΠͰ͖Δ
    (1೔10ճσϓϩΠͨ͠Β୲౰ऀ͸ͦΕ͔͠Ͱ͖ͳ͘ͳΔ)
    ୭Ͱ΋㸜ⰋחσϓϩΠͰ͖Δ࢓૊ΈΛ੔͑Δ

    View full-size slide

  38. 3VOEFDLח״׷رفٗ؎㹋遤

    View full-size slide

  39. 3VOEFDL
    www.rundeck.com/open-source
    Job ఆٛɺ࣮ߦΛߦ͑Δ Automation Software
    ϦϞʔτϗετ΁ͷ࣮ߦ΍εέδϡʔϧ࣮ߦ΋(LobiͰ͸࢖͍ͬͯͳ͍)
    σϓϩΠʹඞཁͳίϚϯυΛୟͨ͘Ίͷ Web UI ͱͯ͠ར༻
    • EC2, ECS, Lambda ͷσϓϩΠ / ϩʔϧόοΫ
    • Chef ʹΑΔϓϩϏδϣχϯά
    • Terraform ʹΑΔߏ੒มߋ
    • ΦʔτεέʔϦϯάͷૢ࡞(୆਺Λ૿΍͢ͳͲ)

    View full-size slide

  40. رفٗ؎㾶娖׾盖椚ׅ׷
    ͍ͭԿ͕σϓϩΠ͞Εͨͷ͔Λه࿥͍ͨ͠
    • ໰୊ൃੜ࣌ ԿΛσϓϩΠͨ͠ޙʹൃੜͨ͠ͷ͔
    • ͍ͭσϓϩΠ͍ͯ͠Δͷ͔ (ۀ຿࣌ؒ֎/ٳલ೔ɺٳ೔)
    github.com/Songmu/ghch
    Git ͷཤྺ͔Β ChangeLog Λࣗಈੜ੒͢Δπʔϧ
    Git TagΛݩʹɺ௚લͷσϓϩΠͱࠓճͷσϓϩΠ·Ͱͷࠩ෼Λ࡞Δ

    View full-size slide

  41. HIDIדرفٗ؎חろת
    ׸׷13׾《䖤׃ג鎸ꐮ
    ghch --from $recent_tag
    {
    "pull_requests": [
    {
    "number": 23013,
    "state": "closed",
    "title": "...........",
    Google ΧϨϯμʔʹه࿥
    Mackerel ͷάϥϑΞϊςʔγϣϯʹه࿥

    View full-size slide

  42. 4MBDLCPUח״׷
    رفٗ؎ך盖椚
    ຊདྷ͸ϨϏϡʔΞαΠϯ/ PR ͷϥϕϧ෇͚Λα
    ϙʔτ͢Δ Slack App (bot)
    ςετ͕௨͍ͬͯͳ͔ͬͨΓ
    ࣌ؒ֎ͷσϓϩΠΛߦ͓͏ͱ͢Δͱܯࠂ͢Δ

    View full-size slide

  43. ؝ٝذش獳遤䖓ךرفٗ؎

    View full-size slide

  44. ؝ٝذش獳遤䖓ךرفٗ؎
    ݱࡏγεςϜશମΛ EC2 ͔Β Amazon ECS ʹҠߦத
    Կ͕มΘΔ͔
    CI: มΘΒͳ͍
    Ϗϧυ: EC2 → CircleCI (image build)
    ꂁ䋒ծٗ٦ٕغحؙ4USFUDIFS̔&$4
    ؒٓ٦嗚濼/PSJLSB̔'JSFIPTF4-BNCEB

    View full-size slide

  45. &$4חֶֽ׷رفٗ؎
    1. ίϯςφΠϝʔδΛ࡞Δ
    2. λεΫఆٛΛొ࿥
    3. αʔϏε͕ར༻͢ΔλεΫఆٛΛߋ৽
    4. ECS ͕αʔϏε಺ͷλεΫΛೖΕ׵͑Δ
    2, 3 Λߦ͏σϓϩΠπʔϧΛ։ൃ
    github.com/kayac/ecspresso

    View full-size slide

  46. FDTQSFTTP
    github.com/kayac/ecspresso
    γϯϓϧ / ϛχϚϧͳ ECS σϓϩΠπʔϧ (Go੡)
    • λεΫͱαʔϏεఆٛΛ JSON ͔Βੜ੒, ొ࿥
    • σϓϩΠ = αʔϏεͷλεΫఆٛΛೖΕ׵͑Δ
    • ϩʔϧόοΫ = ௚લͷλεΫఆٛʹࠩ͠ସ͑Δ
    AWS SDK Go ͷߏ଄ମΛ࢖͏͜ͱͰ৽ػೳͷΩϟονΞοϓΛ༰қʹ
    (ྫ: EFSϚ΢ϯτػೳ 1/18ϦϦʔε → 1/20ରԠ൛ ecspresso ϦϦʔε)
    Blue/Green deployment ͸ CodeDeploy ͱ࿈ܞ͢Δ͜ͱͰαϙʔτ

    View full-size slide

  47. 傀㶷&$4؟٦ؽأ׾盖椚⻉ח
    init αϒίϚϯυΛ࣮ߦ͢Δͱ
    $ ecspresso init --region ap-northeast-1 --cluster default --service myservice --config config.yaml
    2019/10/12 01:31:48 myservice/default save service definition to ecs-service-def.json
    2019/10/12 01:31:48 myservice/default save task definition to ecs-task-def.json
    2019/10/12 01:31:48 myservice/default save config to config.yaml
    config.yaml, ecs-service-def.json, ecs-task-def.json ͕ੜ੒͞ΕΔ
    λεΫఆٛΛదٓॻ͖׵͑ͯ deploy ͢Δ͚ͩͰҠߦՄೳ
    $ ecspresso deploy --config config.yaml
    ଞͷπʔϧ΍ίϯιʔϧͰ࡞ͬͨ ECS λεΫ/αʔϏε΋
    ؆୯ʹίʔυ؅ཧʹམͱ͠ࠐΊΔ

    View full-size slide

  48. أ؛٦ٓـٕזؒٓ٦嗚濼
    Norikra ͸εέʔϧ͕೉͍͠
    1. ϩάΛ Firehose ͔Β S3 ʹ1෼͝ͱʹอଘ
    2. S3 ͷΠϕϯττϦΨͰ Lambda Λىಈ
    3. ϩάͷதʹ͋ΔΤϥʔΛݕग़ͯ͠௨஌
    1෼୯ҐͰݕग़ͯ͠௨஌Λൃੜͤ͞Δཁ݅Λ
    อͪͭͭϚωʔδυʹ
    ྲྀྔ͕૿͑ͯ΋ Firehose / S3 / Lambda
    ͸εέʔϧ͢Δ

    View full-size slide

  49. תה׭
    ߏ੒ཁૉΛ͢΂ͯߴ଎Խ͢Δ͜ͱͰσϓϩΠαΠΫϧΛߴ଎Խ͢Δ
    CI / ഑෍ / Τϥʔݕ஌ / ϩʔϧόοΫ
    ͩΕͰ΋҆શʹɺଈ࠲ʹσϓϩΠͰ͖Δ࢓૊Έ͸։ൃମݧʹॏཁ
    EC2 ͔Β ECS(ίϯςφ)ʹͳͬͯ΋ߟ͑ํ͸ಉ͡
    ΑΓεέʔϧ͠΍͍͢ߏ੒ʹ͍ͯ͘͠

    View full-size slide