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

tfnotify - Show Terraform execution plan beauti...

BABAROT
September 11, 2018

tfnotify - Show Terraform execution plan beautifully on GitHub

BABAROT

September 11, 2018
Tweet

More Decks by BABAROT

Other Decks in Technology

Transcript

  1. tfnotify @b4b4r07 (Sep 11, 2018) / HashiCorp Meetup #3
 DevOps

    Λࢧ͑Δࠓ࿩୊ͷ HashiCorp πʔϧ܈ʹ͍ͭͯ Show Terraform execution plan beautifully on GitHub
  2. ͳͥඞཁͱͳͬͨͷ͔ • ϝϧΧϦͰ͸ Microservices ྖҬͰ Terraform Λར༻͍ͯ͠Δ • Ownership ͷ؍఺͔ΒΠϯϑϥ؅ཧʹ͓͍ͯ΋ϨϏϡʔɾϚʔδ͸

    ֤ Micorservices νʔϜʹΑͬͯ͞ΕΔ΂͖ • ͱ͸͍ͬͯ΋ɺPlatform νʔϜʹϨϏϡʔ͞Ε͍ͨέʔε΋͋Δ
  3. ͳͥඞཁͱͳͬͨͷ͔ • Platform νʔϜͱͯ͠΋ɺ֤ Microservices νʔϜͱͯ͠΋ɺ
 Infrastructure as Code ͷॏཁੑΛཧղ͠

    Terraform ͰίʔυԽ͠ɺ ͦͷ࣮ߦܭըΛຖճݟΔ͜ͱΛश׳͚͍ͮͨ • ຖ೔ଟ͘ͷ P-R ͕͋ΔதɺCircle CI ʹݟʹ͍͘खؒΛল͖͍ͨ →ϨϏϡʔͷྲྀΕͰ GitHub ্ͰΫΠοΫʹ֬ೝ͍ͨ͠
  4. ϝϧΧϦͰͷ HashiCorp πʔϧ • ϝϧΧϦʹ͸ 70 Ҏ্ͷ Microservices ͕͋Δ
 (ࠓ೔ݱࡏɽ૿͑ଓ͚͍ͯΔ)

    • ͢΂ͯͷ Microservices ͱͦͷ Platform ͷ
 Πϯϑϥߏஙʹ͸ Terraform Λར༻͍ͯ͠Δ • Developers ʹ Infrastructure as Code Λ
 ࣮ફͯ͠΋Β͏
  5. ϝϧΧϦͰͷ Terraform ར༻ࣄྫ • Insights • 110+ Contributors • 8

    ~ 10 Pull Requests / week (5 days) • 140+ state files (70+ Microservices * 2 Env) • ͻͱͭͷதԝϦϙδτϦͰ͢΂ͯͷ Terraform ίʔυΛ؅ཧ͍ͯ͠Δ • CI pipeline ͷߏங͕Ұ౓ͰࡁΉ • Platform νʔϜ͕ϨϏϡʔʹೖΓ΍͍͢
  6. ϦϙδτϦߏ੒ • ֤ Microservice ͝ͱʹ
 σΟϨΫτϦΛ෼͚Δ • Service ͝ͱʹ tfstate

    Λ෼͚Δ • ӨڹΛଞ΁೾ٴͤ͞ͳ͍ • Resource ͝ͱʹ file Λ෼͚Δ • Ϧιʔεఆٛ৔ॴΛ໌֬Խ • CODEOWNERS Ͱݖݶҕৡ
  7. ϦϙδτϦߏ੒ • ֤ Microservice ͝ͱʹ
 σΟϨΫτϦΛ෼͚Δ • Service ͝ͱʹ tfstate

    Λ෼͚Δ • ӨڹΛଞ΁೾ٴͤ͞ͳ͍ • Resource ͝ͱʹ file Λ෼͚Δ • Ϧιʔεఆٛ৔ॴΛ໌֬Խ • CODEOWNERS Ͱݖݶҕৡ தԝूݖ ཱࣗ෼ࢄ
  8. ݖݶҕৡ IUUQTCMPHHJUIVCDPNJOUSPEVDJOHDPEFPXOFST • GitHub ͷػೳ • CODEOWNERS ʹهࡌ͞Ε ͨਓ͔Β Approve

    ͞ΕΔ
 ·ͰϚʔδͰ͖ͳ͍Α͏ʹ Ͱ͖Δ • ͜ΕʹΑΓݖݶҕৡΛ࣮ݱ • (উखʹมߋͰ͖ͳ͍)
  9. Ϟδϡʔϧ • microservices-starter-kit (Terraform Ϟδϡʔϧ) • Template Provider Λ࢖͍σΟϨΫτϦ࡞੒ɺϑΝΠϧు͖ग़͠ •

    Microservices ͷ্ཱͪ͛ʹඞཁͳϦιʔεΛ Bootstrap ͢Δ • GCP Project, Service account ͳͲ • PagerDuty, DataDog, Kubernetes (Namespace, Secret) ͳͲ • GitHub Teams (CODEOWNERS ͷݖݶҕৡʹ࢖͏) IUUQTTQFBLFSEFDLDPNCCSUFSSBGPSNPQTGPSNJDSPTFSWJDFT
  10. ࣮૷ • io.TeeReader Λ࢖͍ͬͯΔ • GitHub ʹ POST ͢Δ͚ͩͰ͸ ͳ͘

    CI ͷ Console ʹ΋ग़ྗ • Terraform ͷ࣮ߦ݁Ռ͸ࣗલͷ ύʔαͰߏ଄Խ͢Δ (regexp) • POST ͢Δϝοηʔδ͸ Go ͷ
 ςϯϓϨʔτͰॻ͘͜ͱ͕Ͱ͖Δ • ઃఆ͸ YAML Ͱ࣋ͭ
  11. ·ͱΊ • ϝϧΧϦͰ͸ Microservices ྖҬͰ Terraform Λར༻͍ͯ͠Δ • ूݖͱ෼ࢄͷόϥϯεͰ Terraform

    ϦϙδτϦΛӡ༻͍ͯ͠Δ • ͨ͘͞Μͷ P-R Λޮ཰Α͘ϨϏϡʔ͢ΔͨΊ tfnotify Λॻ͍ͨ • Terraform ͷ࣮ߦ݁ՌΛखܰʹ֬ೝ͍ͨ͠ • Infrastructure as Code ͷจԽΛࠜ෇͔ͤΔ • ຖճ plan, apply ݁ՌΛݟΔश׳Λ΋ͭ / ΋ͬͯ΋Β͏ • ઌߦ࣮૷͕ͳ͍ͨΊ OSS ʹͨ͠