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
Blue/Green deploymentへの道のり
Search
Hirokazu Sugiuchi
October 20, 2016
Technology
1
120
Blue/Green deploymentへの道のり
2016/10/07 社内勉強会で発表した資料です
Hirokazu Sugiuchi
October 20, 2016
Tweet
Share
More Decks by Hirokazu Sugiuchi
See All by Hirokazu Sugiuchi
FFLT_12.pdf
critical_alert
0
68
AWS認定 ソリューションアーキテクトアソシエイトを受けてきた話
critical_alert
1
350
Hue で始める おうちハック入門
critical_alert
1
2.1k
入門Let's Encrypt
critical_alert
2
2.3k
Mackerelでサーバ監視はじめた話
critical_alert
0
1.6k
Other Decks in Technology
See All in Technology
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
300
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.6k
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
Can We Measure Developer Productivity?
ewolff
1
150
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
500
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
990
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
いざ、BSC討伐の旅
nikinusu
2
780
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
170
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
520
Featured
See All Featured
Side Projects
sachag
452
42k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
4 Signs Your Business is Dying
shpigford
180
21k
Practical Orchestrator
shlominoach
186
10k
Docker and Python
trallard
40
3.1k
Thoughts on Productivity
jonyablonski
67
4.3k
Designing the Hi-DPI Web
ddemaree
280
34k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Done Done
chrislema
181
16k
Transcript
Blue/Green deploymentͷಓͷΓ 2016/10/07 feedforce Inc. / Hirokazu Sugiuchi
࠷ۙBlue/Green deployment ʹڽͬͯ·͢
ࢥ͍ΛͤΔ͏ͪʹௐͨΓ ͨ͜͠ͱଟ͘ͳ͖ͬͯͨͷ Ͱ͜ͷลͰ Blue/Green deploymentɹ ͱԿ͔ɺ ͲΜͳํ๏Ͱ࣮ݱͰ͖Δͷ͔ ·ͱΊ͓ͯ͜͏ͱࢥ͍·ͨ͠
τϐοΫ • Blue/Green deployment ͱԿ͔ • AWSʹ͓͚Δ Blue/Green ͷํ๏͍Ζ͍Ζ •
Blue/Green deployment ͷಓͷΓ • ʓʓ • ·ͱΊ
Ͱɺͦͦ Blue/Green deployment ͬͯͳΜͩ
Blue/Green deploymentͱ deployͷʹ৽͍͠ڥΛ ༻ҙͯ͠Γସ͑Δํ๏
Blue/Green deployment • Martin FowlerࢯʹΑΔϒϩάΤϯτϦ͕༗໊ • http://martinfowler.com/bliki/ BlueGreenDeployment.html • ຊ൪ڥΛೋͭ(blueڥɺgreenڥɺ)༻ҙͯ͠
৽͍͠όʔδϣϯͷΞϓϦέʔγϣϯ/αʔόΛยํ ͷڥʹσϓϩΠ͠τϥϑΟοΫΛΓସ͑Δɺͱ͍ ͏ϦϦʔεํ๏
AWSʹ͓͚Δ Blue/Green ͷ ํ๏͍Ζ͍Ζ
DNSΓସ͑ํࣜ • DNSϨίʔυͷ͖ઌΛBlue͔ΒGreenεΠον ͢Δ • round robinͰঃʑʹΣΠτΛௐ͠εΠον͢Δ • (ऑ) TTL
ʹҾͬுΒΕΔͷͰίϯτϩʔϧͮ͠Β ͍
ELB + ASG Γସ͑ํࣜ • DNSͻͱͭͷELBΛࢦͨ͠··ͰELBʹͿΒԼ͛Δ ASG ΛεΠον͢Δ • Auto
Scaling ࠷ۙॻ͍ͨQiitaهࣄΛࢀরͯͩ͘͠ ͍͞ • ͜Ε https://feedforce.qiita.com/critical-alert/items/ 1a39749d838d29b5631a
ECSΓସ͑ํࣜ • ίϯςφΛ͏ • ࠓ͞ͳ͍
ҙࣝ
͍·ͷࢲʹ͋Γ͕ͪͳ͜ͱ • Χʔωϧʹ੬ऑੑ͕...ύονͯͨ͋ͱ࠶ىಈ͠ͳ͍ͱ • 1ͮͭ ELB ͔ΒΓ͠ → 1ͮͭͤͬͤͱ yum
update → ࠶ىಈ → ELB ʹ͢ • όοναʔόͦΖͦΖ͍ͬͺ͍͔ͩΒΠϯελϯε1૿͠·͠ΐ͏ • ΠϯελϯεىಈˠChefͰϓϩϏδϣχϯάˠΞϓϦέʔγϣϯίʔυͷσϓϩΠɻ खಈͰΔͷ໘͍ͩ͠... • OSͷΞοϓσʔτ͕͍ͨ͠ • Ξοϓσʔτͯ͠ಈ͔ͳ͘ͳͬͨͲ͏͠Α͏ • ৽͘͠αʔό૿ͨ͠Βͦͷ yum update ͢Δʁ
ͳͥBlue/Green͍͔ͨ͠ • ELBͷ͖ઌΛม͑Δ͚ͩ • θϩμϯλΠϜϦϦʔε • ͕͋Εݩͷڥʹ͢ͱϩʔϧόοΫ • ൿͷλϨΛࢭ͢Δ •
(Immutable Infrastructure)
λϨͷ݅ • Chef Ͱίʔυཧ͞Ε͍ͯͯɺServerspe Λॻ͍ ͍ͯͯ·৽͘͠αʔόཱͯͨΒͪΌΜͱಈ͘ͷ͔ʁ ͱ͍͏ෆ͕͖҆ͭ·ͱ͏ɻ(පؾ͔͠Εͳ͍) • Blue/Green ͩͱڧ੍తʹ৽͍͠αʔόΛཱͯΔ͜ͱ
ʹͳΔͷͰҟৗ͕͋ͬͨͱͯ͠ݪҼٻ͕͍͢͠ • ͍εύϯͰԿཱͯΔ͜ͱͰλϨԽΛ͙
ΠϯελϯεΛࣺͯ͘͢͢Δ • ΠϯϑϥͷίʔυԽ(࠶ݱ͘͢͠Δ) • ૄ݁߹ʹ͓ͯ͘͠ • ফ͑ͯࠔΔϑΝΠϧϩά֎ʹอଘ͢Δ • ࣗಈԽ͕ඞਢ
Blue/Green deploymentɹ ͷಓͷΓ
Γӽ͑ͳ͍ͱ͍͚ͳ͍՝
ʓʓ • AMIͲ͏͢Δ • ΞϓϦέʔγϣϯͷσϓϩΠͲ͏͢Δ • ϩάͲ͏͢Δ
DockerԽ͠·͢
ऴ
!
αʔϏεΠϯ·Ͱͷϓϩηε(ݱࡏ) • 1.ΠϯελϯεΛىಈ͢Δ • 2.ChefͰϓϩϏδϣχϯάΛ͢Δ • 3.CapistranoͰΞϓϦέʔγϣϯίʔυΛɹɹɹ σϓϩΠ͢Δ • 4.ELBʹΠϯελϯεΛͿΒԼ͛Δ
2ͱ3͕͍ɻ ͢ΔͱAMIΛ࡞ΓࠐΉ͔ɹɹ ͱ͍͏ʹͳΔɻ
AMIͲ͏͢Δ • શ෦ೖΓ • OS,ϛυϧΣΞઃఆ,ΞϓϦέʔγϣϯίʔυ • ௨শΰʔϧσϯΠϝʔδ • ͚ͩઃఆࡁΈ •
OS,ϛυϧΣΞͷΈઃఆࡁΈ(ChefͰϓϩϏδϣχϯά͚ͩ͢Δ) • ࠷খߏ(͍·͜͜) • OSͷΈ
શ෦ೖΓ • ҡ࣋͢Δϋʔυϧ͕ߴ͍ • ىಈ͢Δ͚ͩͰαʔϏεΠϯՄೳ͕ͩɹɹɹ ΞϓϦέʔγϣϯίʔυ͕ߋ৽͞ΕΔͨͼʹ AMIΛ࡞Δඞཁ͕͋Δ
͚ͩઃఆࡁΈ • Chef ͰϓϩϏδϣχϯάΛࡁ·ͤͨঢ়ଶͰAMIΛ࡞ ͢Δ • ΞϓϦέʔγϣϯίʔυΑΓߋ৽සগͳ͍ • ىಈ͖ͯͨ͠ΒΞϓϦέʔγϣϯίʔυΛσϓϩΠ͠ ͯαʔϏεΠϯ
• ͳ͔ͳ͔ݱ࣮తͳϥΠϯ
AMIԽPackerΛ͏ https://www.packer.io/
ΞϓϦέʔγϣϯͷσϓϩΠɹ Ͳ͏͢Δ
ΞϓϦέʔγϣϯͷσϓϩΠɹ Ͳ͏͢Δ • ͔ͤͬ͘ϓϩϏδϣχϯάࡁΈͷΠϯελϯε͕ىಈ ͯ͠ίʔυ͕ແ͍ͱαʔϏεΠϯͰ͖ͳ͍ • CapistranoΛखಈͰ࣮ߦ͔… • Auto Scaling
Ͱىಈͨ͠ΒखಈͰ࣮ߦͳΜͯͬͯΒ Εͳ͍ • ࣗ͜͜ಈԽ͠ͳ͍ͱ͍͚ͳ͍
Πϯελϯε͕ىಈͨ͠Βɹ ࣗͰΞϓϦέʔγϣϯίʔ υΛ࣋ͬͯ͘ΔΑ͏ʹ͍ͨ͠
PullܕDeploy • Consul + stretcher (dragonͰ࠾༻) • AWS Code Deploy(֯ߴΊ/MakerͰͬͯ
ͨʁ) • EC2 Run Command(ະௐ͍͍ࠪͱ͜Ζ)
·ͩ·ͩݕ౼தɻ
ϩάͲ͏͢Δ • Fluentd ͓͚͍͍ͬͯ • ࠷ۙͷྲྀΕ Fluentd ܦ༝Ͱ Big Query
• ͔Βͷ Re:dash ͰՄࢹԽͰ͠ΐ͏͔
͜͜·ͰΕ৸ͯΔؒʹ Auto Scaling ͰΠϯελϯε ͕૿͑ͯউखʹαʔϏεΠ ϯͯ͘͠ΕΔ
ࠓ Auto Scaling ಋೖͯ͠Δ ͱ͜ΖͰ͢
Α͏͘ͷ΅Γ͡Ί͔ͨ Γ͔ͩΒͳ ͜ͷͯ͠ͳ͘ɹ ԕ͍Blue/GreenࡔΛΑ (͜ͷΜʹը૾)
͓·͚
ͦΕDockerͰry
ͦΕDockerͰͰ͖ΔΑ • Ҏ্ͷΑ͏ͳ͜ͱΛߟ͍͑ͯΔͱ Docker ͷϙʔλ ϏϦςΟΰΠεʔͬͯؾ࣋ͪʹͳͬͯ͘Δ • ΞϓϦέʔγϣϯίʔυͱΞϓϦέʔγϣϯ࣮ߦ ڥΛίϯςφʹ·ͱΊΔ͜ͱͰ͚ͯߟ͑ͳ͍ͯ͘ ͍Α͏ʹྑ͘ͳΔͷΠΠ
• ΰʔϧσϯΠϝʔδઓ๏ΛͬͯEC2͕ىಈ͢Δ ࣌ؒΛॖ͢Δ͜ͱ΄΅ෆՄೳʹ͍ۙ
·ͱΊ
·ͱΊ • DockerΛ͑ʂ • ΞϓϦέʔγϣϯରԠͰ͖ΔͳΒΔՁ͋Δ • ͋ͱ࠷ॳ͔Β Docker લఏͰ࡞Δ •
Blue/Green deployment ͱԿ͔આ໌ͨ͠ • αʔόΛࣺͯ͘͢͢ΔʹͲ͏͢Δ͔આ໌ͨ͠ • ͍Ζ͍Ζͳ͕͋Δ͜ͱΛઆ໌ͨ͠