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
430
この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
390
自己組織的な開発チームを如何にして作り上げるか / how to build self-organizing team
kiririmode
8
9k
なぜぼくがbitcoinに心惹かれるのか
kiririmode
1
970
Other Decks in Technology
See All in Technology
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
520
Lexical Analysis
shigashiyama
1
150
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
390
AIチャットボット開発への生成AI活用
ryomrt
0
160
Windows Autopilot Deployment by OSD Guy
tamaiyutaro
0
420
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.1k
組み込みLinuxの時系列
puhitaku
4
1.1k
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
110
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
830
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
200
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
250
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
150
Featured
See All Featured
Statistics for Hackers
jakevdp
796
220k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Scaling GitHub
holman
458
140k
Ruby is Unlike a Banana
tanoku
96
11k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Speed Design
sergeychernyshev
24
610
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
A Tale of Four Properties
chriscoyier
156
23k
Rails Girls Zürich Keynote
gr2m
94
13k
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