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
70
AWS認定 ソリューションアーキテクトアソシエイトを受けてきた話
critical_alert
1
360
Hue で始める おうちハック入門
critical_alert
1
2.1k
入門Let's Encrypt
critical_alert
2
2.3k
Mackerelでサーバ監視はじめた話
critical_alert
0
1.7k
Other Decks in Technology
See All in Technology
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
270
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
130
2024年にチャレンジしたことを振り返るぞ
mitchan
0
140
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
540
UI State設計とテスト方針
rmakiyama
2
660
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
250
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
210
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
120
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
230
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
170
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
270
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
360
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
The Pragmatic Product Professional
lauravandoore
32
6.3k
The Invisible Side of Design
smashingmag
298
50k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Docker and Python
trallard
42
3.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Mobile First: as difficult as doing things right
swwweet
222
9k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
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 ͱԿ͔આ໌ͨ͠ • αʔόΛࣺͯ͘͢͢ΔʹͲ͏͢Δ͔આ໌ͨ͠ • ͍Ζ͍Ζͳ͕͋Δ͜ͱΛઆ໌ͨ͠