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
このConsulがすごい!/consul is great!
Search
Yuichi Kiri
August 03, 2018
Technology
0
440
このConsulがすごい!/consul is great!
中央線Meetup#1 での発表資料です
https://chuoline.connpass.com/event/93685/
Yuichi Kiri
August 03, 2018
Tweet
Share
More Decks by Yuichi Kiri
See All by Yuichi Kiri
CloudNativeなサービス用環境を構築するツールキット Eponaを作った/toolkit to create cloud-native environment for our services
kiririmode
0
400
自己組織的な開発チームを如何にして作り上げるか / how to build self-organizing team
kiririmode
8
9.1k
なぜぼくがbitcoinに心惹かれるのか
kiririmode
1
980
Other Decks in Technology
See All in Technology
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
150
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
なぜCodeceptJSを選んだか
goataka
0
160
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
マイクロサービスにおける容易なトランザクション管理に向けて
scalar
0
110
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
MLOps の現場から
asei
6
630
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
110
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
祝!Iceberg祭開幕!re:Invent 2024データレイク関連アップデート10分総ざらい
kniino
2
250
kargoの魅力について伝える
magisystem0408
0
200
Featured
See All Featured
Code Review Best Practice
trishagee
65
17k
Unsuck your backbone
ammeep
669
57k
Mobile First: as difficult as doing things right
swwweet
222
9k
Fireside Chat
paigeccino
34
3.1k
It's Worth the Effort
3n
183
28k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Building an army of robots
kneath
302
44k
Faster Mobile Websites
deanohume
305
30k
Optimizing for Happiness
mojombo
376
70k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Transcript
͜ͷConsul͕͍͢͝ தԝઢMeetup #1 2018/08/03 (ۚ) ར༑Ұ @kiririmode
ࣗݾհ ɾLJSJSJNPEF ɾؒࣄΛ͢Έ ͚͍ͭͮͯΔ
ࣗݾհ ɾ͗ͬ͘Γࠊ ͳ͓ͬͨͣͩͬͨ
ࠓͷςʔϚ $POTVM
ࠓͷςʔϚ ͍͑ͨ ͍͍
ConsulͬͯͳΜ HashiCorp͕ͭͬͯ͘Δɺ ࣗࢄγεςϜ༻ͷ Swiss-Army-Knife IUUQTXXXWJDUPSJOPYDPNHMPCBMFO1SPEVDUT4XJTT"SNZ,OJWFT-BSHF1PDLFU,OJWFT8PSL$IBNQQΑΓ
ConsulͰԿ͕Ͱ͖ΔΜ • Ϋϥελߏஙɺϝϯόγοϓཧ • ϔϧενΣοΫ • αʔϏεσΟεΧόϦ • K/V ετΞ
• ࢄΠϕϯτॲཧ • ࢄϩοΫ/ࢄηϚϑΥ • αʔϏεؒ௨৴ͷAuth(N/Z)௨৴҉߸Խ (mTLS) • ଞProductͱΈ߹ͤΔͱ͞ΒͳΔՄೳੑ
ConsulͷԿ͕͍͔͢͝ • SPoFͷͳ͍ΞʔΩςΫνϟ • ݸʑͷϊʔυͰͷࣗతͳނোݕग़ͱϝϯόγοϓཧ • ࣗࢄతͳϦʔμʔબग़ͱ߹ҙܗ • ϊʔυؒͰͷ(ڧ|݁Ռ)߹ੑΛ࣋ͬͨใڞ༗ ੲʹࢥ͍ඳ͍͍ͯͨ
ࣗࢄγεςϜͷະདྷ ଟͷϊʔυ͕ ʮάϧʔϓʯΛܗ͢Δͱ͜Ζʹ׆༂ͷ͕͋Δ όΠφϦͰ Մೳ
Consul͕ඞཁͱͳΔഎܠ • ಈతͳϊʔυՃ/আ͕ΨϯΨϯى͜Γ ͯΜΘΜ͢Δ • MicroServices • Auto Scaling •
Node ނো • ͦΜͳڥͰ͋ͬͯϊʔυ ڠௐ͠ԿΒ͔ͷతΛՌͨ͞ͶͳΒ͵ զʑͱ͓ͳ͡Ͱ
͜ͷʹ: ਓྨزͱͳ͘ઓ͠ ഊΛ܁Γฦ͖ͯͨ͠
ࣦഊͷຊ࣭ ຊͷେ౦ѥઓ૪࢙ΛࣾձՊ ֶతʹݟͯͦ͠ͷഊͷ࣮ ମΛ໌Β͔ʹ͢ΕɺͦΕ ഊઓͱ͍͏൵ࢂͳܦݧͷ͏͑ ʹங͔ΕͨฏͱൟӫΛڗड ͖ͯͨ͠ΘΕΘΕͷੈʹͱͬ ͯɺ͖ΘΊͯେ͖ͳҙຯΛ࣋ ͭ͜ͱʹͳΔͷͰͳ͍͔ (͕͖͠)
ࣦഊͷຊ࣭ •աڈͷޭମݧʹաదԠ͠ ͯ͠·͍ৗʹมಈ͍ͯ͠ ͘ઓɾઓگʹॊೈʹద Ԡ͍ͯ͘͜͠ͱ͕Ͱ͖ͳ͔ ͬͨ
େͳ͜ͱ • มಈ͍ͯ͠Δڥʹ͓͍ͯ ඞཁͱ͢Δਖ਼͍͠ใ͕֤ࣗͰ ಘΒΕΔ͜ͱ
None
ΞʔΩςΫνϟ • Agentܕɻ֤ϊʔυʹΠϯετʔϧ͢Δɻ • AgentʹServerɺClientͷ2छྨ͕ଘࡏ͢Δ • Client: • ࣗϊʔυࣗͱࣗϊʔυ্ͷαʔϏεΛࢹ •
GossipingʹΑΓಈతʹΫϥελΛߏ • 1Ϋϥελ͋ͨΓʙઍorສ • Server: • Client͔ΒͷใΛͱʹΫϥελϨϕϧͷใΛ·ͱΊͯอ࣋ • 1Ϋϥελ͋ͨΓ3͋Δ͍5͕جຊ /PEF JOTUBMM
$POTVM$MVTUFS ED ΞʔΩςΫνϟ - Server/Client • RaftΛ͍ΫϥελશମʹؔΘΔσʔλΛ ߹ੑͷऔΕͨܗͰอ࣋ɾڞ༗ $POTVM$MVTUFS ED
$POTVM4FSWFST $POTVM"HFOUT • Agent͕Service/NodeͷϔϧενΣοΫ • Service/Nodeεςʔλεɺϝϯόγοϓतड • ΫϥελϨϕϧͷใServerʹ߹ͤ $POTVM4FSWFST $POTVM"HFOUT • Raft: ίϯηϯαεϓϩτίϧ • αʔόؒͰͷථʹΑΓϦʔμʔΛબग़ • Ϧʔμʔαʔόͷ߹ҙΛܦͨΫϥελͷ ঢ়ଶ/ใΛଞαʔόʹϨϓϦέʔγϣϯ • ผDC্ͷαʔόͱGossipingͰใΛڞ༗ ɾ/PEF4FSWJDF4UBUVT ɾ,FZ7BMVF4UPSF ɾFUD - (PTTJQJOH 48*. 3BGU - "OUJ&OUSPQZ ਪʙDMVTUFS
ΞʔΩςΫνϟ - ͍߹ΘͤͷྲྀΕ $POTVM$MVTUFS ED $POTVM4FSWFST $POTVM"HFOUT - - ҙͷαʔόʹ͍߹Θͤ
Ϧʔμʔʹ͍߹Θͤ • ͍߹ΘͤʹϦʔμʔ͕ճ • ڧ߹ੑΛอ࣋ • ҰํͰΫϥελϫΠυͷσʔλଞαʔ όอ࣋ • RaftͷϨϓϦέʔγϣϯܦ༝ • Ϧʔμʔ͕ࢮΜͰସ͑Εྑ͍ ͨͩ͠ɺαʔϏεσΟεΧόϦ σϑΥͩͱ݁Ռ߹ੑɻ͜ͷ͋ͨΓઃఆՄ /P41P' DPOTVMLWHFUSFEJTDPOpHDPOO
ཁ͢ΔʹConsulͱ • ࢄڥʹ͓͍ͯ • SPoFͳ͠ʹ • ߹ੑΛ࣋ͬͨใΛ • ڞ༗Ͱ͖Δ
ConsulͰͰ͖Δ͜ͱΛ ΫϥελͰڞ༗͢Δσʔλ͔Βߟ͑ͯΈΔ
αʔϏεͷࢮ׆ใͷڞ༗ • • web͔ΒaccountαʔϏεʹAPI call͍ͨ͠ • webͲͷIPΞυϨεʹAPIΛૹΕྑ͍͔ • ͨͩ͠
accountαʔϏεࣗಈతʹ૿ݮ͢Δͷͱ͢Δ XFC BDDPVOU BDDPVOU BDDPVOU
αʔϏεͷࢮ׆ใͷڞ༗ • • web͔ΒaccountαʔϏεʹAPI call͍ͨ͠ • webͲͷIPΞυϨεʹAPIΛૹΕྑ͍͔ • ͨͩ͠
accountαʔϏεࣗಈతʹ૿ݮ͢Δͷͱ͢Δ XFC BDDPVOU BDDPVOU BDDPVOU -#ͷ7*1 -# ɾ-#͕41P'ʹͳͬͪΌ͏ʜ ˠ-#Λ)"ʹ͢Δͱ·ͨ৭ʑ໘ʹʜ ɾBDDPVOUαʔϏε͕૿ݮͨ͠ͱ͖ͷ-#ϧʔϧөͲ͏͢Δʜ ɾଞαʔϏε͕Ճ͞Εͨͱ͖-#͑ΒΕΔʜ
αʔϏεͷࢮ׆ใͷڞ༗ • • web͔ΒaccountαʔϏεʹAPI call͍ͨ͠ • webͲͷIPΞυϨεʹAPIΛૹΕྑ͍͔ • ͨͩ͠
accountαʔϏεࣗಈతʹ૿ݮ͢Δͷͱ͢Δ XFC BDDPVOU BDDPVOU BDDPVOU BDDPVOUTFSWJDFDPOTVM "HFOUʹzBDDPVOUzαʔϏεͷଘࡏΛొ IFBMUIZͳαʔϏεΛ࣋ͭϊʔυΛ%/4)551ͰDPOTVMʹ߹ͤ EJH TIPSUBDDPVOUTFSWJDFDPOTVM 3PVOE3PCJOͰฦͬͯ͘ΔͷͰɺෛՙࢄ༰қ
Service Discoveryͷ߹ͤΫΤϦΛڞ༗ • • DC1ͷPostgreSQL(pg)͕ΕͨΒDC2ͷpgʹFailover͍ͨ͠ QH QH BDDPVOU %$
%$
1. Prepared QueryΛొ 2.
Prepared QueryΛར༻ͯ͠DNS lookup DVSMSFRVFTU1045EBUBb\ l/BNFzlQHGBJMPWFSz l4FSWJDFzlQHz l'BJM0WFSz\ l%BUBDFOUFSTz<lEDz lEDz> ^ ^`IUUQWRVFSZ ҙͷϊʔυʹొ͓͚ͯ͠ɺ Ϋϥελશମʹൖ͢Δ EJH TIPSUQHGBJMPWFSRVFSZDPOTVM %JTDPWFSZઌ ϩʔΧϧͳ%$ͷ1( EDͷ1( EDͷ1( 1SFQBSFE2VFSZͷ5FNQMBUFػೳΛ͑ɺ Ұʑ֤αʔϏε༻ʹ2VFSZΛॻ͔ͳͯͭ͘ͷ 2VFSZ͚ͩͰ'BJMPWFSΛ࣮ݱͰ͖·͢ Service Discoveryͷ߹ͤΫΤϦΛڞ༗
ઃఆใͷڞ༗ • • ಈతʹ૿ݮ͢ΔϊʔυؒͰઃఆใΛڞ༗͍ͨ͠ • ઃఆใ͕มߋ͞ΕͨΒ௨ͯ͠΄͍͠ DPOTVMLWQVUSFEJTDPOpHDPOO - ,FZ7BMVFͷΛڞ༗
DPOTVMLWHFUSFEJTDPOpHDPOO DPOTVMXBUDIUZQFLFZQSFpY QSFpYSFEJTTDSJQUTIBOEMFSTI SFEJTԼͷ͕มΘͬͨΒ ϋϯυϥ࣮ߦ
ϩοΫͷڞ༗ • • NͷMWΛৗ࣌Քಈ͍͕ͤͨ͞ɺ Մ༻ੑͷͨΊʹ͞Βʹ1ΛHot Standby͓͖͍ͤͯͨ͞ DPOTVMMPDLOMPDLLFZ`QBUIUPNXTUBSUTIIPHF` .8ىಈ .8ىಈ
ϩοΫղআɺϊʔυͷނো-FBEFSมߋͰൃੜɻ αϒϓϩηεʹ4*(5&3.ˠඵˠ4*(,*-- PO-JOVY DPOTVMMPDLOMPDLLFZ`QBUIUPNXTUBSUTIIPHF` DPOTVMMPDLOMPDLLFZ`QBUIUPNXTUBSUTIIPHF` ϩοΫ͕֎ΕΔ·Ͱػɻ ֎ΕͨλΠϛϯάͰίϚϯυ࣮ߦɻ ϩοΫऔಘ༻ͷΩʔ ϩοΫऔಘޭ࣌ʹ࣮ߦ͞ΕΔίϚϯυ
ূ໌ॻ/ൿີ伴ͷڞ༗ • • αʔϏεؒ௨৴Λ҉߸Խ͢ΔͱͱʹೝূɾೝՄΛߦ͍͍ͨ (TLS encryption + auth(n|z)) TJEFDBS
QSPYZ "1*$BMMUP BOPUIFSTFSWJDF DFSU BVUI[ TJEFDBS QSPYZ DFSU BVUI[ XJUIFODSZQUJPO \DMJFOU TFSWFS^DFSU $POTVM$POOFDUΛ༗ޮԽ αʔϏεؒ௨৴ͷϧʔϧઃఆ DPOTVMJOUFOUJPODSFBUFBMMPXXFCBDDPVOU ɾ$POTVM͕ূ໌ॻͱϧʔϧ *OUFOUJPO Λڞ༗ ɾ$POTVMʹରԠͨ͠1SPYZ͕ྑ͠ͳʹ 5-4ɺ"VUI[Λѻͬͯ͘ΕΔ XFC BDDPVOU
·ͱΊ • ConsulࢄڥͰใڞ༗Λߦ͏ͨΊͷπʔϧ • ڞ༗͢ΔใʹΑͬͯϢʔεέʔεͷ͕ ͕Δ • ୯ମͰ: • Service
Discovery, KV Store(Deployment, Feature Toggle, etc.), Service Mesh, etc. • ଞϓϩμΫτͱͷΈ߹Θͤ: • consul-template, consul-esm, fabio, envoy