Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tfnotify - Show Terraform execution plan beauti...
Search
BABAROT
September 11, 2018
Technology
5
13k
tfnotify - Show Terraform execution plan beautifully on GitHub
https://hashicorp.connpass.com/event/98386/
BABAROT
September 11, 2018
Tweet
Share
More Decks by BABAROT
See All by BABAROT
SLOをゼロからつくる
b4b4r07
15
5.8k
Cloud Functions in Go at Mercari
b4b4r07
9
5.6k
Insert an Example of Software Engineer Here
b4b4r07
4
1.8k
Kubernetes manifests management and operation in Mercari
b4b4r07
27
6.8k
Testing with YAML
b4b4r07
5
5k
Micoservices Platform in Mercari
b4b4r07
3
150
Terraform Ops for Microservices
b4b4r07
16
15k
シェルスクリプトを書く技術
b4b4r07
3
1k
Other Decks in Technology
See All in Technology
いまからでも遅くない! コンテナでWebアプリケーションを 動かしてみよう(2-1)WebAPI座学
nomu
0
150
山手線一周のパフォーマンス改善
suzukahr
0
150
【shownet.conf_】ShowNet 2024 ~ Inter * Network ~
shownet
PRO
0
490
LeSSはスクラムではない!?LeSSにおけるスクラムマスターの振る舞い方とは / Scrum Master Behavior in LeSS
toma_sm
0
170
ドメインと向き合う - 旅行予約編
hidenorigoto
4
550
入門 バックアップ
ryuichi1208
18
6.5k
XPを始める新人に伝えたい近道の鍵
nakasho
1
300
スタサプ ForSCHOOLアプリのシンプルな設計
recruitengineers
PRO
2
440
All your memory are belong to… whom?
ennael
PRO
0
640
小さな勉強会の始め方、広げ方、あるいは友達の作り方 / How to Start, Grow, and Build Connections with Small Study Groups
ar_tama
6
2.4k
第45回 MLOps 勉強会 - ML Test Score を用いた機械学習システムの定量的なアセスメント
masatakashiwagi
3
290
OPENLOGI Company Profile for engineer
hr01
1
12k
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
1
280
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
A designer walks into a library…
pauljervisheath
202
24k
Teambox: Starting and Learning
jrom
131
8.7k
Designing Experiences People Love
moore
138
23k
Atom: Resistance is Futile
akmur
261
25k
Being A Developer After 40
akosma
84
590k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
110
6.9k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Unsuck your backbone
ammeep
668
57k
WebSockets: Embracing the real-time Web
robhawkes
59
7.3k
Designing for humans not robots
tammielis
249
25k
Transcript
tfnotify @b4b4r07 (Sep 11, 2018) / HashiCorp Meetup #3 DevOps
Λࢧ͑Δࠓͷ HashiCorp πʔϧ܈ʹ͍ͭͯ Show Terraform execution plan beautifully on GitHub
BABAROT / @b4b4r07 Mercari, Inc. SRE, Microservices Platform Blog /
tellme.tokyo
1. mercari/tfnotify 2. Why tfnotify? 3. Implementations Agenda
mercari/tfnotify
• Go CLI πʔϧ • Terraform ͷ࣮ߦ݁ՌΛύʔε͠ɺ దͳϑΥʔϚοτʹ͋ͯΊͯɺ ҙͷ௨ઌ
(GitHub ͷίϝϯτ) ௨͢Δ tfnotify ͱ
tfnotify Workflow DSFBUFE UFSSBGPSNQMBOcUGOPUJGZQMBO 1045DPN N FOU PVUQVU
tfnotify Workflow N FSHFE UFSSBGPSNBQQMZcUGOPUJGZBQQMZ 1045DPN N FOU PVUQVU
Example • fmt • plan • apply
Example {{.Title}} {{.Message}} {{.Result}} {{.Body}} ࣮ߦग़ྗͯ͢ ࣮ߦ݁ՌͷαϚϦ --messageͰͤΔ ҙͷλΠτϧ
Why tfnotify?
ͳͥඞཁͱͳͬͨͷ͔ • ϝϧΧϦͰ Microservices ྖҬͰ Terraform Λར༻͍ͯ͠Δ • Ownership ͷ؍͔ΒΠϯϑϥཧʹ͓͍ͯϨϏϡʔɾϚʔδ
֤ Micorservices νʔϜʹΑͬͯ͞ΕΔ͖ • ͱ͍ͬͯɺPlatform νʔϜʹϨϏϡʔ͞Ε͍ͨέʔε͋Δ
ͳͥඞཁͱͳͬͨͷ͔ • Platform νʔϜͱͯ͠ɺ֤ Microservices νʔϜͱͯ͠ɺ Infrastructure as Code ͷॏཁੑΛཧղ͠
Terraform ͰίʔυԽ͠ɺ ͦͷ࣮ߦܭըΛຖճݟΔ͜ͱΛश׳͚͍ͮͨ • ຖଟ͘ͷ P-R ͕͋ΔதɺCircle CI ʹݟʹ͍͘खؒΛল͖͍ͨ →ϨϏϡʔͷྲྀΕͰ GitHub ্ͰΫΠοΫʹ֬ೝ͍ͨ͠
ϝϧΧϦͰͷ HashiCorp πʔϧ
ϝϧΧϦͰͷ HashiCorp πʔϧ • ϝϧΧϦʹ 70 Ҏ্ͷ Microservices ͕͋Δ (ࠓݱࡏɽ૿͑ଓ͚͍ͯΔ)
• ͯ͢ͷ Microservices ͱͦͷ Platform ͷ Πϯϑϥߏஙʹ Terraform Λར༻͍ͯ͠Δ • Developers ʹ Infrastructure as Code Λ ࣮ફͯ͠Β͏
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ • Insights • 110+ Contributors • 8
~ 10 Pull Requests / week (5 days) • 140+ state files (70+ Microservices * 2 Env) • ͻͱͭͷதԝϦϙδτϦͰͯ͢ͷ Terraform ίʔυΛཧ͍ͯ͠Δ • CI pipeline ͷߏங͕ҰͰࡁΉ • Platform νʔϜ͕ϨϏϡʔʹೖΓ͍͢
ϦϙδτϦߏ • ֤ Microservice ͝ͱʹ σΟϨΫτϦΛ͚Δ • Service ͝ͱʹ tfstate
Λ͚Δ • ӨڹΛଞٴͤ͞ͳ͍ • Resource ͝ͱʹ file Λ͚Δ • ϦιʔεఆٛॴΛ໌֬Խ • CODEOWNERS Ͱݖݶҕৡ
ϦϙδτϦߏ • ֤ Microservice ͝ͱʹ σΟϨΫτϦΛ͚Δ • Service ͝ͱʹ tfstate
Λ͚Δ • ӨڹΛଞٴͤ͞ͳ͍ • Resource ͝ͱʹ file Λ͚Δ • ϦιʔεఆٛॴΛ໌֬Խ • CODEOWNERS Ͱݖݶҕৡ தԝूݖ ཱࣗࢄ
ݖݶҕৡ IUUQTCMPHHJUIVCDPNJOUSPEVDJOHDPEFPXOFST • GitHub ͷػೳ • CODEOWNERS ʹهࡌ͞Ε ͨਓ͔Β Approve
͞ΕΔ ·ͰϚʔδͰ͖ͳ͍Α͏ʹ Ͱ͖Δ • ͜ΕʹΑΓݖݶҕৡΛ࣮ݱ • (উखʹมߋͰ͖ͳ͍)
ݖݶҕৡ IUUQTIFMQHJUIVCDPNBSUJDMFTBCPVUDPEFPXOFST
Ϟδϡʔϧ • microservices-starter-kit (Terraform Ϟδϡʔϧ) • Template Provider Λ͍σΟϨΫτϦ࡞ɺϑΝΠϧు͖ग़͠ •
Microservices ͷ্ཱͪ͛ʹඞཁͳϦιʔεΛ Bootstrap ͢Δ • GCP Project, Service account ͳͲ • PagerDuty, DataDog, Kubernetes (Namespace, Secret) ͳͲ • GitHub Teams (CODEOWNERS ͷݖݶҕৡʹ͏) IUUQTTQFBLFSEFDLDPNCCSUFSSBGPSNPQTGPSNJDSPTFSWJDFT
Implementations
࣮ • io.TeeReader Λ͍ͬͯΔ • GitHub ʹ POST ͢Δ͚ͩͰ ͳ͘
CI ͷ Console ʹग़ྗ • Terraform ͷ࣮ߦ݁Ռࣗલͷ ύʔαͰߏԽ͢Δ (regexp) • POST ͢Δϝοηʔδ Go ͷ ςϯϓϨʔτͰॻ͘͜ͱ͕Ͱ͖Δ • ઃఆ YAML Ͱ࣋ͭ
࣮ • ॏෳͨ͠༰͕͋Δ߹ɺ ݹ͍ͷ͕আ͞ΕΔ • ࣮ߦ݁Ռ͍ͷͰ Details λά ͰғͬͯંΓͨͨΈɺҰṮʹඞཁ ͳใ͚͕ͩݟ͘͢දࣔ͞ΕΔ
{{.Title}}, {{.Message}} ͷॏෳΛݟΔ
Conclusion
·ͱΊ • ϝϧΧϦͰ Microservices ྖҬͰ Terraform Λར༻͍ͯ͠Δ • ूݖͱࢄͷόϥϯεͰ Terraform
ϦϙδτϦΛӡ༻͍ͯ͠Δ • ͨ͘͞Μͷ P-R ΛޮΑ͘ϨϏϡʔ͢ΔͨΊ tfnotify Λॻ͍ͨ • Terraform ͷ࣮ߦ݁ՌΛखܰʹ֬ೝ͍ͨ͠ • Infrastructure as Code ͷจԽΛ͔ࠜͤΔ • ຖճ plan, apply ݁ՌΛݟΔश׳Λͭ / ͬͯΒ͏ • ઌߦ࣮͕ͳ͍ͨΊ OSS ʹͨ͠
Thanks