$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
マネージドクラウドとCの世界
Search
sonod
May 23, 2018
Technology
3
660
マネージドクラウドとCの世界
HashiCorp社のConsulとマネージドクラウドのお話
sonod
May 23, 2018
Tweet
Share
More Decks by sonod
See All by sonod
プロダクト開発を通して学んだナレッジマネジメントの哲学
sonod
0
150
誰のためのプロダクト?
sonod
8
3.7k
プロダクトのビルドトラップ
sonod
0
160
Overlay&Underlay Network 僕の思い出
sonod
1
420
OpenStackの攻略本
sonod
1
200
OpenStackの攻略本 第2号
sonod
0
170
物理サーバ構築のここんとこ-MAASのはなしをしまーず-
sonod
5
6.1k
Other Decks in Technology
See All in Technology
日経電子版のStoreKit2フルリニューアル
shimastripe
3
190
今はまだ小さい東京ガス内製開発チームが、これからもKubernetesと共に歩み続けるために
yussugi
3
400
プルリクが全てじゃない!実は喜ばれるOSS貢献の方法8選
tkikuc
12
1.4k
クラウドネイティブなNewSQLで実現するミッションクリティカルなアプリケーションの運用
yuyu_hf
PRO
1
130
情シスの引継ぎが大変という話
miyu_dev
2
470
共創するアーキテクチャ ~チーム全体で築く持続可能な開発エコシステム~ / Co-Creating Architecture - A Sustainable Development Ecosystem Built by the Entire Team
bitkey
PRO
1
3.4k
プラットフォームエンジニアリングアーキテクチャ道場 on AWS & EKS Kubernetes / Platform Engineering Architecture Dojo
riita10069
7
16k
Android 15 でウィジェットピッカーのプレビュー画像をGlanceで魅せたい/nikkei-tech-talk-27-1
nikkei_engineer_recruiting
0
110
Mastering Quickfix
daisuzu
2
440
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
210
RAMP2024
takeyukitamura
3
210
KotlinユーザのためのJSpecify入門 / JSpecify 101 for Kotlin Devs
eller86
0
120
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Building Applications with DynamoDB
mza
90
6.1k
How to Ace a Technical Interview
jacobian
276
23k
Visualization
eitanlees
145
15k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
390
Optimizing for Happiness
mojombo
376
70k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Transcript
ాफҰ(.01&1"#0JOD ϩϦϙοϓʂϚωʔδυΫϥυ::NFFUJOH ϚωʔδυΫϥυͱ$ͷੈք
ΠϯϑϥΤϯδχΞ ాफҰ !OETPFB ϗεςΟϯάࣄۀ෦ϚωʔδυΫϥυνʔϜ
$ͷੈքͱ
ੜࢮʹؔͳ͘ɺ ਓͷ৺ͱهԱ͕ू·Δੈքʢू߹ແҙࣝʣ XJLJQFEJBҾ༻ IUUQTKBXJLJQFEJBPSHXJLJ&#&#$&&"&&"&#@&'%&&"&&"#&"#&#$&#&"&"&&"&#&"&"
ੜࢮʹؔͳ͘ɺ ਓͷ৺ͱهԱ͕ू·Δੈքʢू߹ແҙࣝʣ XJLJQFEJBҾ༻ ίʔυΪΞεٯͷϧϧʔγϡ IUUQTKBXJLJQFEJBPSHXJLJ&#&#$&&"&&"&#@&'%&&"&&"#&"#&#$&#&"&"&&"&#&"&"
ϚωʔδυΫϥυͷ$ͱ
օ͞Μ͜ͷϩΰݟͨ͜ͱ͋Γ·͔͢ʁ
ͦ͏Ͱ͢Ͷ
8IBUJT$POTVM w)BTIJ$PSQ͕ࣾఏڙ͍ͯ͠ΔΫϥελͷཧπʔϧͰ͢ wެࣜϖʔδͪ͜ΒIUUQTXXXDPOTVMJP w(JU)VCͪ͜ΒIUUQTHJUIVCDPNIBTIJDPSQDPOTVM w։ൃݴޠɺ(Pݴޠ
8IBUJT$POTVM w)BTIJ$PSQ͕ࣾఏڙ͍ͯ͠ΔΫϥελͷཧπʔϧͰ͢ʁʁ wެࣜϖʔδͪ͜ΒIUUQTXXXDPOTVMJP w(JU)VCͪ͜ΒIUUQTHJUIVCDPNIBTIJDPSQDPOTVM w։ൃݴޠɺ(Pݴޠ
8IBUJT$POTVM $POTVMIBTNVMUJQMFDPNQPOFOUT CVUBTBXIPMF JUJTBUPPMGPSEJTDPWFSJOHBOEDPOpHVSJOHTFSWJDFTJO ZPVSJOGSBTUSVDUVSF Β͍͠ʂʂ $POTVMʹෳͷίϯϙʔωϯτ͕͋Γ·͕͢ɺ શମͱͯ͠ɺΠϯϑϥετϥΫνϟͷαʔϏεΛൃݟͯ͠ ߏ͢ΔͨΊͷπʔϧͰ͢ɻ
ެࣜతʹ
8IBUJT$POTVM ΠϯϑϥετϥΫνϟͷαʔϏεΛൃݟͯ͠ ߏ͢ΔͨΊͷπʔϧͱʁʁ
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM 4FSWJDF %JTDPWFSZ $POTVMΫϥΠΞϯτͰʮBQJʯʮNZTRMʯͳͲͷαʔϏεΛఆٛ͢Δͱɺ ଞͷΫϥΠΞϯτ$POTVMͰಛఆͷαʔϏεΛൃݟʢ%JTDPWFSZʣ͢Δ͜ͱ͕ग़དྷΔ ·ͨɺ%/4·ͨ)551Λར༻͢Δ͜ͱͰɺ ΞϓϦέʔγϣϯґଘ͍ͯ͠ΔαʔϏεͷใΛ؆୯ʹݟ͚ͭΔ͜ͱ͕ग़དྷΔ ܰ͘۷ΓԼ͛Δͱ
{ "service": { { “name”: “keepalived”, “tags”: [“keepalived”], “checks”: [
{ "script”: "/usr/lib/nagios/plugins/check_procs -c 1: -a keepalived”, “interval”: "30s” } ] } } 8IBUJT$POTVM ˝LFFQBMJWFEKTPO ͜Μͳײ͡Ͱɺ+40/Ͱ$POTVMʹαʔϏεΛఆٛ͢Δͱ
# consul catalog services keepalived # dig keepalived.service.consul ;; ANSWER
SECTION: keepalived.service.consul. 0 IN A 172.16.1.1 # curl http://127.0.0.1:8500/v1/catalog/services | jq. { "weblb-keepalived": [ "weblb-keepalived" ] } 8IBUJT$POTVM $POTVMΫϥΠΞϯτ%/4)551͔Β؆୯ʹಛఆͷαʔϏεΛݟ͚ͭΕΔΑ͏ʹͳΓ·͢
{ "service": { { “name”: “keepalived”, “tags”: [“keepalived”], “checks”: [
{ "script”: "/usr/lib/nagios/plugins/check_procs -c 1: -a keepalived”, “interval”: "30s” } ] } } 8IBUJT$POTVM ˝LFFQBMJWFEKTPO ͜Μͳײ͡Ͱɺ+40/Ͱ$POTVMʹαʔϏεΛఆٛ͢Δͱ ͪͳΈʹ͜ͷϑΝΠϧͰ͕͢
# consul agent -data-dir=/etc/consul # cat /etc/consul/keepalived.json { "service": {
{ “name”: “keepalived”, “tags”: [“keepalived”], “checks”: [ { "script”: "/usr/lib/nagios/plugins/check_procs -c 1: -a keepalived”, “interval”: "30s” } ] } } 8IBUJT$POTVM $POTVMBHFOUΛىಈ͢Δࡍʹࢦఆͨ͠σΟϨΫτϦʹஔ͠·͢ ͜ͷσΟϨΫτϦʹஔ
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM 4FSWJDF %JTDPWFSZ ಛఆͷαʔϏε·ͨϊʔυͷϔϧενΣοΫΛ͢Δ͜ͱ͕ग़དྷΔ αʔϏεͷϔϧενΣοΫʹɺεΫϦϓτ/BHJPTϓϥάΠϯΛ༻Ͱ͖Δ )FBMUI $IFDLJOH ܰ͘۷ΓԼ͛Δͱ
{ "service": { { “name”: “keepalived”, “tags”: [“keepalived”], “checks”: [
{ "script”: "/usr/lib/nagios/plugins/check_procs -c 1: -a keepalived”, “interval”: "30s” } ] } } 8IBUJT$POTVM ˝LFFQBMJWFEKTPO ઌఔɺʮ4FSWJDF%JTDPWFSZʯͰͬͨ+40/ͷઢͰׅހͬͨ෦ͷΑ͏ʹॻ͘͜ͱͰ༻Ͱ͖·͢ ͜Ε/BHJPTϓϥάΠϯΛ༻͍ͯ͠ΔύλʔϯʹͳΓ·͢ɻ
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM 4FSWJDF %JTDPWFSZ $POTVMͷ෦σʔλΛอ͢Δ֊ΩʔόϦϡʔετΞͰɺ ΫϥελͷͲͷϊʔυ͔ΒΞΫηεग़དྷΔΑ͏ʹͳ͍ͬͯΔ ΞϓϦέʔγϣϯʹΑΔಈతઃఆมߋ$POTVMͷϦʔμʔબग़ʹ༻Ͱ͖Δ $POTVMαʔόͱσʔληϯλʔͷใ͍࣋ͬͯΔ ·ͨɺ)551"1*Λ༻͢Δ͜ͱͰ؆୯ʹΞΫηεग़དྷΔ ,74UPSF
8IBUJT$POTVM ҙͱͯ͠ɺWBMVFͷ্ݶ͕,#ͱ͍͏ ͜ͱ͚͓͍֮ͩ͑ͯͯ͑Εͱࢥ͍·͢ IUUQTXXXDPOTVMJPEPDTGBRIUNMRXIBUJTUIFQFSLFZWBMVFTJ[FMJNJUBUJPOGPSDPOTVMTLFZWBMVFTUPSF
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM $POTVMɺҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ɻ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ %BUBDFOUFS
8IBUJT$POTVM 4FSWJDF %JTDPWFSZ ΫϥελʔΛ%BUBDFOUFSͱ͍͏୯ҐͰཧ͓ͯ͠Γɺ ͦͷ%BUBDFOUFSͱҟͳΔ%BUBDFOUFSؒͷ࿈ܞΛαϙʔτ͍ͯ͠·͢ ͦΕͦ͜ཧతͳ%BUBDFOUFSؒΛͭͳ͛ΔΠϝʔδͰ͢ $POTVMతʹɺ ʮ$POTVMͷϢʔβʔ͕ෳͷҬʹ͢ΔͨΊʹ நϨΠϠʔΛՃ͢Δ͜ͱΛ৺͢Δඞཁ͕ͳ͍͜ͱΛҙຯ͠·͢ɻʯ ͱͷ͜ͱͰ͢ɻ
.VMUJ %BUBDFOUFS
8IBUJT$POTVM ͜ͷΑ͏ͳҎԼͷͭͷॏཁͳػೳ͕Έ߹Θ͞Δ͜ͱʹΑΓɺ ࣗಈͰΠϯϑϥͷαʔϏεΛൃݟ͠ઃఆߏΛ͍ͯ͠·͢ͷͰɺ $POTVMɺΠϯϑϥετϥΫνϟͷαʔϏεΛൃݟͯ͠ߏ͢ΔͨΊͷπʔϧ 4FSWJDF %JTDPWFSZ )FBMUI $IFDLJOH ,74UPSF .VMUJ
%BUBDFOUFS
$POTVMͷ"SDIJUFDUVSF
#BTJD"SDIJUFDUVSFPG$POTVM $POTVMʹେ͖͚ͯ̎ͭ͘ͷϞʔυ͕ଘࡏ͠·͢ ʮ4FSWFSʯͱʮ$MJFOUʯͰ͢ ֤ϊʔυɺ$POTVM"HFOUΛىಈ͢Δࡍʹɺ ͜ͷͲͪΒ͔ͷϞʔυΛࢦఆ͠·͢ 4FSWFS $MJFOU
#BTJD"SDIJUFDUVSFPG$POTVM $POTVMͷશͯͷσʔλͷ֨ೲ͠ཧ͢Δׂ $POTVMͷΫϥελΛΉ্ͰඞͣҎ্ඞཁͱͳΓɺ σʔλଛࣦγφϦΦΛආ͚ΔͨΊʹdߏ͕ਪͱ͞Ε͍ͯ·͢ Խʹ͍ͭͯɿ ੑΛอͪͭͭσʔλͷҰ؏ੑΛ୲อ͢ΔͨΊʹɺ ࢄ߹ҙΞϧΰϦζϜͰ͋Δ3BGUϓϩτίϧ͕࠾༻͞Ε͍ͯ·͢ -FBEFS͕બग़͞Εɺଞ'PMMPXFSͱͳΓ·͢ -FBEFSͷΈ͕σʔλΛίϛοτ͠ɺ
'PMMPXFSσʔλΛਵ࣌ϨϓϦέʔγϣϯ͞Ε·͢ 4FSWFS $MJFOU $POTVMαʔόͱ௨৴Λ͠ΫϥελใͷऔಘͱొΛ͢Δׂ $POTVMαʔόͱ௨৴Ͱ͖ͳ͍ͱΫϥελ͔Β֎͞ΕΔ
#BTJD"SDIJUFDUVSFPG$POTVM */5&3/&5 4FSWFS 'PMMPXFS 4FSWFS -FBEFS 4FSWFS 'PMMPXFS $MJFOU $MJFOU
%BUBDFOUFS -"/(044*1 5$16%1 3&1-*$"5*0/ 5$1 3&1-*$"5*0/ 5$1 31$ 5$1 31$ 5$1 -"/(044*1 5$16%1 %BUBDFOUFS -&"%&3 '038"3%*/( 8"/(044*1 5$16%1 3&.05&%$ '038"3%*/( 5$1
#BTJD"SDIJUFDUVSFPG$POTVM (044*1ϓϩτίϧʹ͍ͭͯɿ ͔͜͜Β ϥϯμϜʹબΜͩ૬खͱใΛަ͠ɺ͕ࣗ࣋ͭσʔλͷߋ৽Λ܁Γฦ͢ɻ γεςϜͷࢀՃऀ͕ෆఆظతʹ૿ݮͯ͠શମΛѲͰ͖ͳ͍ঢ়گɺ Ұ࣌తʹ௨৴Ͱ͖ͳ͍߹ͰใΛൖͰ͖Δɻ ͜͜·ͰҾ༻ ΫϥελʔมߋͷӨڹΛड͚ͣʹ௨৴Λߦ͑Δোੑͷߴ͍ใڞ༗ϓϩτίϧΒ͍͠ ʢXJLJQFEJB͔ΒҾ༻ʣ IUUQTKBXJLJQFEJBPSHXJLJΰγοϓϓϩτίϧ
ϚωʔδυΫϥυͱ$POTVM
͔͜͜ΒϚωʔδυΫϥυͰ $POTVMΛ ͍ͬͯΔ෦Λհ͠·͢
$POTVMͷ ͝հͰ͖͍ͯͳ͍ػೳ͕ ·ͩ·ͩ͋ΔͷͰซͤͯ͝հ͠·͢
ϚωʔδυΫϥυͷશମߏ
$POTVMΛ ͍ͬͯΔͷ͕Ͳ͜ͳͷ͔ʂ ϚωʔδυΫϥυͷશମߏ
ϚωʔδυΫϥυͷશମߏ શ෦Ͱ͢Ͷ
ϚωʔδυΫϥυͷશମߏ $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM
$MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM $MJFOU $POTVM 4FSWFS $POTVM 4FSWFS $POTVM 4FSWFS 3&1-*$"5*0/ 5$1 3&1-*$"5*0/ 5$1 31$ 5$1 31$ 5$1 31$ 5$1
ϚωʔδυΫϥυͷશମߏ $POTVM 4FSWFS $POTVM 4FSWFS $POTVM 4FSWFS $POTVM 4FSWFS $POTVM
4FSWFS $POTVM 4FSWFS 4UBHJOH 1SPEVDUJPO ߋʹɺ.VMUJ%BUBDFOUFSߏʹͳ͍ͬͯ·͢ ڑతʹΕͨ%BUBDFOUFSͱ͔Ͱͳ͘ɺোͷӨڹൣғ໊લղܾͷൣғΛͤ͞Δͨ Ίʹ͍ͬͯ·͢ .VMUJ %BUBDFOUFS
ϚωʔδυΫϥυͷશମߏ w ϚωʔδυΫϥυɺશମͰ$POTVMΛ༻͍ͯ͠·͢ w ֤ϊʔυͰ$POTVM͕"HFOUͰىಈ͓ͯ͠ΓαʔϏεొΛߦ͍ͬͯ·͢ w $POTVM4FSWFSͰԽߏʹͳ͍ͬͯ·͢ $POTVM4FSWFS֤%BUBDFOUFSʹඞཁͳͷͰɺ͍ͬͺ͍͋Γ·͢ ͜͜Ͱ$POTVMͷඪ४ػೳͰ͋ΔΜͰ͕͢ɺ Ұ൪͓ੈʹͳ͍ͬͯΔػೳͷ͓Λ
$POTVM%/4
$POTVM%/4 w $POTVMʹɺ%/4ػೳ͕͋Γ·͢ w ϚωʔδυΫϥυͰɺϩʔΧϧͷαʔόͷ໊લղܾΛશͯ$POTVMʹ·͔͍ͤͯ·͢ w σϑΥϧτͰɺOPEFDPOTVMͱ͍͏υϝΠϯ͕͖ͭ·͢ ਖ਼֬ʹɺOPEF\%BUBDFOUFS໊^DPOTVM w αʔϏεΛొ͓͚ͯ͠ɺTFSWJDFDPOTVMͱ͍͏υϝΠϯͰ໊લղܾ͢Δ͜ͱՄೳ
w $POTVM%/4ͷϙʔτͳͷͰɺΞϓϦέʔγϣϯSFTPMW͔Β༻͍ͨ͠߹ ɺEOTNBTRΛ༻͢Δඞཁ͕͋Γ·͢ ϚωʔδυΫϥυͰɺ6OCPVOEΛ༻͍ͯ͠·͢ 4FSWJDF %JTDPWFSZ
$POTVM%/4 $POTVM 4FSWFS $PNQVUF ྫ͑$PNQVUFͱݴΘΕΔϊʔυͰɺ ͜Μͳײ͡Ͱʮ6OCPVOE /4% $POTVMʯͰߏ͍ͯ͠·͢ $POTVM
$MJFOU 6OCPVOE /4% # cat unbound.conf server: interface: 127.0.0.1 do-not-query-localhost: no stub-zone: name: "consul." stub-addr: 172.16.1.1@8600 stub-zone: name: “lolipop.jp.” stub-addr: 172.16.1.1@10053 DPOTVMͩͬͨΒ$POTVM%/4 MPMJQPQKQͩͬͨΒ/4% /BNF4FSWFS%BFNPO ໊લղܾͩ 4FSWJDF %JTDPWFSZ
$POTVM%/4 $POTVMΛىಈ͢Ε)551%/4͕༻ՄೳͱͳΓ·͢ͷͰɺ͜Μͳײ͡Ͱ֬ೝͰ͖·͢ # consul members Node Address Status Type Build
Protocol DC server-1 10.11.1.1:80 alive client 0.9.0 2 dc1 # dig server-1.node.consul ;; ANSWER SECTION: server-1.node.consul. 0 IN A 10.11.1.1 # curl http://127.0.0.1:8500/v1/catalog/nodes|jq .[]
{ "service": { { “name”: “keepalived”, “tags”: [“keepalived”], “checks”: [
{ "script”: "/usr/lib/nagios/plugins/check_procs -c 1: -a keepalived”, “interval”: "30s” } ] } } ˝LFFQBMJWFEKTPO αʔϏεͷ߹ɺ͜Μͳײ͡Ͱ+40/Ͱ$POTVMʹαʔϏεΛఆٛ͢Δͱ $POTVM%/4 4FSWJDF %JTDPWFSZ
# dig keepalived.service.consul ;; ANSWER SECTION: keepalived.service.consul. 0 IN A
172.16.1.1 keepalived.service.consul. 0 IN A 172.16.1.2 ͜Μͳײ͡ͰTFSWJDF୯ҐͰͷ໊લղܾΛ͢Δ͜ͱͰ͖·͢ $POTVM%/4 ͍ͭͮͯ 4FSWJDF %JTDPWFSZ
$POTVM5FNQMBUF
$POTVM5FNQMBUF w (JU)VCͪ͜ΒIUUQTHJUIVCDPNIBTIJDPSQDPOTVMUFNQMBUF w $POTVMͷঢ়ଶมԽΛࢹ͢ΔσʔϞϯ w $POTVMͷ,74ͷใΛ)551ܦ༝Ͱৗʹࢹ͍ͯ͠Δ w $POTVMͷԿ͔͠ΒͷΠϕϯτ ϊʔυͷ૿ݮ
͕ൃੜͨ͠ࡍʹɺςϯϓϨʔτϑΝΠϧΛͱ ʹઃఆϑΝΠϧΛ࠶࡞͠ίϚϯυͷ࣮ߦ σʔϞϯͷ࠶ىಈ Λͯ͘͠ΕΔ ,74UPSF )FBMUI $IFDLJOH 4FSWJDF %JTDPWFSZ
$POTVM5FNQMBUF ͜Μͳ࣌ʹ͍ͬͯΔ$POTVM5FNQMBUF Ұ൪ଟ͍ύλʔϯ͕͜͏͍ͬͨ3FWFSTF1SPYZͷ૿ݮΛࣗಈతʹ࣮ࢪ͢Δͱ͜ΖͰ͢ -PBE #BMBODFS 3FWFSTF 1SPYZ 3FWFSTF 1SPYZ 3FWFSTF
1SPYZ -PBE #BMBODFS 3FWFSTF 1SPYZ 3FWFSTF 1SPYZ 3FWFSTF 1SPYZ ઃఆ͕ࣗಈͰॻ͖ΘΓɺΓ͞ΕΔ ઃఆ͕ࣗಈͰॻ͖ΘΓɺ-PBE#BMBODFSʹՃ͞ΕΔ 3FWFSTF 1SPYZ ˝3FWFSTF1SPYZ͕%PXO ˝ 3FWFSTF1SPYZΛ"%% 3WFSTF1SPYZΛΓͨ͠ઃఆΛ࡞ͯ͠࠶ىಈ 3FWFSTF1SPYZΛՃͨ͠ઃఆΛ࡞ͯ͠࠶ىಈ ,74UPSF )FBMUI $IFDLJOH 4FSWJDF %JTDPWFSZ
͜Μͳײ͡Ͱઃఆͱ5FNQMBUFΛॻ͍ͯஔ͓͚ͯͩ͘͠Ͱউखʹͬͯ͘Ε·͢ʂศརʂ # cat keepavilved.conf.ctmpl virtual_server 172.1.1.1 80 { delay_loop 10
lvs_sched rr lvs_method NAT protocol TCP {{range service "reverseproxy|passing"}} real_server {{.Address}} 80 { weight 1 TCP_CHECK { connect_port 80 connect_timeout 30 } }{{end}} } $POTVM5FNQMBUF ## cat config.hcl consul { address = "127.0.0.1:8500" ssl { enabled = false } } pid_file = "/var/run/consul-template/pid" template { source = "/etc/consul-template/keepalived.conf.ctmpl" destination = “/etc/keepalived/conf.d/reverseproxy.conf" command = "sudo systemctl reload keepalived" } SFWFSTFQSPYZͷαʔϏεΛྻʹͯ͠ ͦΕΛશͯొ͠·͢ ϊʔυͷ*1ΞυϨε ஔͯ͠σʔϞϯΛSFMPBE ˝5FNQMBUF ˝$POTVM5FNQMBUFͷઃఆ ,74UPSF )FBMUI $IFDLJOH 4FSWJDF %JTDPWFSZ
$POTVMBMFSUT
$POTVMBMFSUT w (JU)VCͪ͜ΒIUUQTHJUIVCDPN"DBMFQI4UPSBHFDPOTVMBMFSUT w $POTVMͷαʔϏεϊʔυͷมԽ͕ൃੜͨ͠ࡍʹɺ.BJM4MBDLʹ௨Λͯ͘͠ΕΔ σʔϞϯ w ϚωʔδυΫϥυͰɺ4MBDL௨Λ͓ͯ͠Γ͜Μͳײ͡Ͱ௨ͯ͘͠Ε·͢ ,74UPSF
)FBMUI $IFDLJOH 4FSWJDF %JTDPWFSZ
$POTVMFYQPSUFS
$POTVM͔Βएׯ֎Ε͖ͯͯΔ͕ $POTVMFYQPSUFS
$POTVMFYQPSUFS w (JU)VCͪ͜ΒIUUQTHJUIVCDPNQSPNFUIFVTDPOTVM@FYQPSUFS w $POTVMͷαʔϏεͷঢ়ଶΛ1SPNFUIFVTʹసૹ͢ΔσʔϞϯ w ϚωʔδυΫϥυͷࢹج൫1SPNFUIFVTΛ༻͍ͯ͠·͢ͷͰɺ ϊʔυͷঢ়ଶཧͷͨΊʹ༻͍ͯ͠·͢ 1SPNFUIFVTʹ͍ͭͯɿ
ͬ͘͟Γઆ໌͢Δͱɺ༷ʑͳϝτϦΫεΛ࣌ܥྻͰ͍͍ײ͡ʹूܭɾهͰ͖ΔπʔϧͰ͢ ৄ͘͠ฐࣾVE[VSBͷ͜ͷลΓͷهࣄΛݟͯΒ͑Δͱྑ͍͔ͱࢥ͍·͢ IUUQTVE[VSBIBUFOBCMPHKQFOUSZ IUUQTTQFBLFSEFDLDPNVE[VSBNBOBHFEDMPVEXJUIQSPNFUIFVT ,74UPSF )FBMUI $IFDLJOH 4FSWJDF %JTDPWFSZ
$POTVMFYQPSUFS .FUSJD .FBOJOH DPOTVM@VQ $POTVMͷ࠷ޙͷ2VFSZ͕ޭ͔ͨ͠ DPOTVM@TFSG@MBO@NFNCFST Ϋϥελʔͷϝϯόʔ DPOTVM@DBUBMPH@TFSWJDFT Ϋϥελʔʹؚ·ΕΔαʔϏε DPOTVM@DBUBMPH@TFSWJDF@OPEF@IFBMUIZ
ϊʔυ্ͷαʔϏε͕ਖ਼ৗ͔ DPOTVM@IFBMUI@OPEF@TUBUVT ϊʔυʹؔ࿈͚ΒΕͨϔϧενΣοΫͷεςʔλε DPOTVM@IFBMUI@TFSWJDF@TUBUVT αʔϏεʹؔ࿈͚ΒΕͨϔϧενΣοΫͷεςʔλε શ෦Ͱͳ͍͕औಘͰ͖Δใ͜ͷΑ͏ͳײ͡Ͱɺ 1SPNFUIFVTଆ͔Β͜ͷΑ͏ͳײ͡Ͱ֬ೝ͢Δ͜ͱ͕Ͱ͖·͢
ଞʹ৭ʑ͍ͬͯΔ෦͋ΔΜͰ͕͢ ࠓճ࣌ؒͷ্ؔ͜͜·ͰͰɾɾɾ
·ͱΊ
$POTVMΛ͏ͱ؆୯ʹ ΫϥελʔཧΛ͢Δ͜ͱ͕Ͱ͖ͯɺ ϊʔυͷཧΛָͰ͖Δ 1.
ϩʔΧϧͷ%/4ొͷखؒ 1SPNFUIFVTͰͷϊʔυཧͷखؒͳͲ ͕Ϳ͚Δ 2.
αʔϏε୯ҐͰϔϧενΣοΫͰ͖ΔͷͰ ϊʔυͷ૿ݮରԠোݕΛ ؆୯ʹग़དྷΔ 3.
ͭ·Γ
ϚωʔδυΫϥυ $POTVMΛͬͯҰ෦ͷӡ༻Λָͯ͠·͢
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠