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.7k
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
1.1k
Other Decks in Technology
See All in Technology
君は隠しイベントを見つけれるか?
mujyun
0
290
omakaseしないための.rubocop.yml のつくりかた / How to Build Your .rubocop.yml to Avoid Omakase #kaigionrails
linkers_tech
3
730
Jr. Championsになって、強く連携しながらAWSをもっと使いたい!~AWSに対する期待と行動~
amixedcolor
0
190
[AWS JAPAN 生成AIハッカソン] Dialog の紹介
yoshimi0227
0
150
「視座」の上げ方が成人発達理論にわかりやすくまとまってた / think_ perspective_hidden_dimensions
shuzon
2
2.2k
話題のGraphRAG、その可能性と課題を理解する
hide212131
4
1.5k
VPC間の接続方法を整理してみた #自治体クラウド勉強会
non97
1
840
分布で見る効果検証入門 / ai-distributional-effect
cyberagentdevelopers
PRO
4
700
Gradle: The Build System That Loves To Hate You
aurimas
2
150
とあるユーザー企業におけるリスクベースで考えるセキュリティ業務のお話し
4su_para
3
320
ガバメントクラウド単独利用方式におけるIaC活用
techniczna
3
270
MAMを軸とした動画ハンドリングにおけるAI活用前提の整備と次世代ビジョン / abema-ai-mam
cyberagentdevelopers
PRO
1
110
Featured
See All Featured
Designing for Performance
lara
604
68k
A better future with KSS
kneath
238
17k
Happy Clients
brianwarren
97
6.7k
What's in a price? How to price your products and services
michaelherold
243
12k
Thoughts on Productivity
jonyablonski
67
4.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
GitHub's CSS Performance
jonrohan
1030
460k
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