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
マネージドクラウドと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
180
誰のためのプロダクト?
sonod
8
3.7k
プロダクトのビルドトラップ
sonod
0
170
Overlay&Underlay Network 僕の思い出
sonod
1
420
OpenStackの攻略本
sonod
1
200
OpenStackの攻略本 第2号
sonod
0
180
物理サーバ構築のここんとこ-MAASのはなしをしまーず-
sonod
5
6.1k
Other Decks in Technology
See All in Technology
ABWGのRe:Cap!
hm5ug
1
110
アジャイルチームが変化し続けるための組織文化とマネジメント・アプローチ / Agile management that enables ever-changing teams
kakehashi
3
3.2k
Amazon Q Developerで.NET Frameworkプロジェクトをモダナイズしてみた
kenichirokimura
1
190
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
140
20241228 - 成為最強魔法使!AI 實時生成比賽的策略 @ 2024 SD AI 年會
dpys
0
350
20240513 - 框裡框外_文學院學生如何在AI世代安身立命 @ 淡江大學
dpys
0
650
AWS Community Builderのススメ - みんなもCommunity Builderに応募しよう! -
smt7174
0
150
新しいスケーリング則と学習理論
taiji_suzuki
10
3.8k
Bring Your Own Container: When Containers Turn the Key to EDR Bypass/byoc-avtokyo2024
tkmru
0
840
いま現場PMのあなたが、 経営と向き合うPMになるために 必要なこと、腹をくくること
hiro93n
9
7k
Building Scalable Backend Services with Firebase
wisdommatt
0
110
iPadOS18でフローティングタブバーを解除してみた
sansantech
PRO
1
110
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
How STYLIGHT went responsive
nonsquared
96
5.3k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Optimizing for Happiness
mojombo
376
70k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
A designer walks into a library…
pauljervisheath
205
24k
How to train your dragon (web standard)
notwaldorf
89
5.8k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Bash Introduction
62gerente
610
210k
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ΛͬͯҰ෦ͷӡ༻Λָͯ͠·͢
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠