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はなめらかか?
Search
KONDO Uchio
May 18, 2016
Technology
6
2.5k
Consulはなめらかか?
https://ezukatechnight.doorkeeper.jp/events/44585
E-zuka tehc night #ezuka_tech_night
KONDO Uchio
May 18, 2016
Tweet
Share
More Decks by KONDO Uchio
See All by KONDO Uchio
大規模レガシーテストを 倒すための CI基盤の作り方 / #CICD2023
udzura
5
2.3k
Ruby x BPF in Action / RubyKaigi 2022
udzura
0
190
Narrative of Ruby & Rust
udzura
0
170
開発者生産性指標の可視化 / pepabo-four-keys
udzura
3
1.6k
Talk of RBS
udzura
0
390
Re: みなさん最近どうですか? / FGN tech meetup in 2021
udzura
0
700
Dockerとやわらかい仮想化 - ProSec-IT/SECKUN 2021 edition -
udzura
2
670
Device access filtering in cgroup v2
udzura
1
760
"Story of Rucy" on RubyKaigi takeout 2021
udzura
0
710
Other Decks in Technology
See All in Technology
エンジニアが一生困らない ドキュメント作成の基本
naohiro_nakata
2
150
製造現場のデジタル化における課題とPLC Data to Cloudによる新しいアプローチ
hamadakoji
0
210
データ活用促進のためのデータ分析基盤の進化
takumakouno
2
540
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
エンジニア候補者向け資料2024.11.07.pdf
macloud
0
4.5k
Mini Tokyo 3D × PLATEAU - 公共交通デジタルツインにリアルな風景を
nagix
1
230
Windows Autopilot Deployment by OSD Guy
tamaiyutaro
0
310
形式手法の 10 メートル手前 #kernelvm / Kernel VM Study Hokuriku Part 7
ytaka23
5
760
End of Barrel Files: New Modularization Techniques with Sheriff
rainerhahnekamp
0
280
TinyGoを使ったVSCode拡張機能実装
askua
2
200
ライブラリでしかお目にかかれない珍しい実装
mikanichinose
2
340
マルチモーダルデータ基盤の課題と観点
neonankiti
1
110
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
32
1.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Fireside Chat
paigeccino
33
3k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Navigating Team Friction
lara
183
14k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Transcript
$POTVMͷ׆༻ํ๏࠶ߟ GMO Pepabo, Inc. Uchio Kondo E-Zuka Tech Night @
2016-05-18 $POTVM ͳΊΒ͔͔ʁ
None
ເͷ͖ͭͮ
NF
None
ۙ౻͏͓ͪ (.0ϖύϘॴଐ ٕज़ج൫νʔϜ Ԭࢧࣾۈ 'VLVPLBSC
3BJMT(JSMT'VLVPLB૯߹ࡶ༻ίʔν·ͱΊ
None
ࣗಈԽ
ӡ༻ͷࣗಈԽ
ൿͷλϨ
खॱॻ
खॱʹखଓ͖ ʹϓϩάϥϛϯάͰ͖Δ
ࣗಈԽ
खॱॻˠ ࣗಈԽ
ͬͱࠜຊతͳϧʔϧ ʢʴࣗੑʣˠ ͳΊΒ͔ͳγεςϜ
͔ͳ❓
$POTVM
ΦʔέετϨʔγϣϯ
ΦʔέετϨʔγϣϯ ❓
*OGSBTUSVDUVSFBT$PEF Πϯϑϥͷ͓ࣄΛɺίʔυͰ 0SDIFTUSBUJPO $POpHVSBUJPO #PPUTUSBQQJOH
*OGSBTUSVDUVSF0SDIFTUSBUJPO5PPMT 5FSSBGPSN$MPVE'PSNBUJPOͷΑ͏ͳɺ *BB4্ͰαʔόωοτϫʔΫετϨʔδͱ ͍ͬͨϦιʔεΛ੍ޚ͢ΔͨΊͷπʔϧαʔ Ϗε $POTVM FUDE ;PP,FFQFSͷΑ͏ͳ
$POpHVSBUJPO3FHJTUSZ
SFGT *OGSBTUSVDUVSFBT$PEF࠶ߟ IUUQNJ[[ZPSHCMPH
$POpHVSBUJPO 3FHJTUSZ
ઃఆ߲Λ ෳͷαʔόͰڞ༗͢Δ
3BGU$POTFOTVT "MHPSJUIN
None
ࢄ߹ҙΞϧΰϦζϜ
4FFQBQFST IUUQTXXXVTFOJYPSHTZTUFNpMFT DPOGFSFODFBUDBUDQBQFS POHBSPQEG ຊޠͰͷղઆ IUUQTHJTUHJUIVCDPNTJMF BEDFCGE
DGϒϩοΫνΣʔϯ ͯ͞ɺϒϩοΫνΣʔϯ৫తࢄܕͷܥΛલఏͱͨ͠ ͷͰ͢ɻͦͯ͠ɺෳͷࢀՃऀ͕ಉ͡ϒϩοΫ͔Βಉ ͡ϒϩοΫνΣʔϯΛܾఆ͢Δͱ͍͏ͷ͕ਖ਼ʹ߹ҙܗͰ ͢ SFGTIUUQOFYUCMPDLDIBJOOFU CMPDLDIBJOBCJMJUZ
ࢄγεςϜʹ͓͚Δ߹ҙ ͱ
ެࣜͷઆ໌ )PMEPOXIBUJTDPOTFOTVT $POTFOTVTJOWPMWFTNVMUJQMFTFSWFSTBHSFFJOHPO WBMVFT IUUQTSBGUHJUIVCJP
ෳͷαʔό͕ ಉ͡ʹ͍ͭͯ߹ҙ͢Δ
ز͔ͭͷαʔό͕ յΕ͍ͯͯɺ ͪΌΜͱ߹ҙͰ͖Δ DG2VPSVN IUUQTXXXDPOTVMJPEPDTJOUFSOBMTDPOTFOTVTIUNM
εςʔτϚγϯͷෳ
IUUQTDPNNPOTXJLJNFEJBPSHXJLJ'JMF$15'4..FBMZTWH
DG,74
DG3BGUͷ3VCZ࣮ IUUQTHJUIVCDPNDFMMVMPJEqPTT '4.ͱͯ͠ϋογϡΛͬͨྫ
$POTVMͱ ߹ҙΞϧΰϦζϜΛ༻͍ͯෳͷαʔόؒͰ εςʔτΛڞ༗͠ɺ ͦΕΛ༻͍ͯαʔόӡ༻ͷࣗಈԽΛߦ͏͜ͱ Ͱ͖Δπʔϧ
FHDPOTVMFYFDͷத ίϚϯυͷதΛ,74Ͱڞ༗͢Δ ड͚औͬͨϊʔυͦΕΛ࣮ߦ͢Δ ऴΘͬͨΒফ͢
Πϕϯτ
Ϋϥελͷ ঢ়ଶͷมԽΛࢹ
XBUDIͰ͖Δͷ ͬ͘͟Γͭ OPEFTϊʔυͷՃআ TFSWJDFTϊʔυͰಈ͘αʔϏεͷঢ়ଶ DIFDLTϊʔυ্ͷαʔϏεͷϔϧενΣοΫࢹͷঢ় ଶ
LFZLFZQSFpYϊʔυؒͰڞ༗͍ͯ͠Δ,74ͷத FWFOUҙͷΠϕϯτ
ྫͰ͢
ϩʔυόϥϯαʔͷ ಈతϝϯόʔՃ
͓खॱ ϝϯόʔҰཡΛࢹ͢Δ Ұཡͷσʔλ+40/ͰಘΒΕΔ ͦΕΛ3VCZͳͲͰ৯ͯઃఆϑΝΠϧΛࣗಈ Ͱ࡞Ε0,
ϝϯόʔҰཡΛࢹ > consul watch -type checks -service nginx
Ұཡͷσʔλ+40/ͰಘΒΕΔ Πϕϯτʹ ϊʔυͷՃআɺ ϔϧενΣοΫͷঢ়ଶมߋ Πϕϯτ͕ى͜Δͱ ࣗಈͰ+40/͕ҙͷ ίϚϯυʹ͍ͬͯ͘
ͦΕΛ3VCZͳͲͰ৯ͯ ઃఆϑΝΠϧΛࣗಈͰ࡞Ε0, ʢੜʹޭͨ͠ΒϦϩʔυʣ
#!/usr/bin/env ruby require 'json' data = STDIN.read @nodes = []
JSON.parse(data).each do |node| if node["Checks"].find {|c| c["CheckID"] == "service:nginx" && c["Status"] == "passing" } @nodes << "#{c["Node"]["Address"]}:#{c["Service"]["Port"]}" end end template = <<ERB upstream backend_apps { <% for node in @nodes %> server <%= node %>; <% end %> } server { listen 80; # .... location / { proxy_pass http://backend_apps; } } ERB require 'erb' open("/etc/nginx/dynamic.conf", "w") do |f| f.write ERB.new(template).run(binding) end
ࢀߟ DPOTVMUFNQMBUFͱ͍͏͕ͭதͰେମಉ͡ ͜ͱΛ͍ͯ͠·͢ IUUQTHJUIVCDPNIBTIJDPSQDPOTVM UFNQMBUF
ͬͱ۩ମྫ
ྫTUSFUDIFS
TUSFUDIFS QVMMܕσϓϩΠϛυϧΣΞͷύΠΦχΞ IUUQTHJUIVCDPNGVKJXBSBTUSFUDIFS !GVKJXBSB͞Μ࡞ɺ(P
͓खॱ σϓϩΠΠϕϯτΛൃՐ͢Δ ˠT͔ΒϚχϑΣετΛऔΔ ˠUBSCBMMΛऔΔ ˠల։ɺޙॲཧ
σϓϩΠΠϕϯτͷൃՐ > consul event -name deploy_production ˞Ұճ͚ͩൃߦ͢Ε0,
֤αʔόʔ ͦΕͧΕͷαʔόͰconsul watchͷίϚϯ υΛɺσʔϞϯͱ্ཱ͓ͯͪ͛ͯ͘͠ ൃՐͨ͠ΠϕϯτΛड͚औͬͯιʔεΛQVMM ͦͯ͠ల։ɺඞཁʹԠ͡ΞϓϦͷϦϩʔυ
αʔόʔ͕ʹͳͬͯඇৗʹ͍࣌ؒͰ ө͞ΕΔΑ͏ʹͰ͖Δ
ྫ5-4TFTTJPO UJDLFUͷڞ༗
5-4TFTTJPOUJDLFUͱ 5-4ͷηογϣϯ伴Λอଘ͠ɺ࠶ར༻͢Δ Έ͕͋Δɻ ͦͷࡍɺෳͷαʔόͷ߹ɺ҉߸ԽͷͨΊͷ Ϛελ伴Λڞ༗͢Δඞཁ͕͋Δ ˠલํൿಗੑͷ؍͔Βɺఆظߋ৽͕ඞཁ
ˠ͔͠શಉ࣌ʹʂ ࢀߟCMPHLB[VIPPLVDPNGPSXBSETFDSFDZIUNM
ΠϕϯτΛλΠϚʔʹֻ͚Δ FHTZTUFNEͷλΠϚʔϢχοτ
ൃՐˠߋ৽ˠϦϩʔυ গ͚ͩ͠λΠϜϥά͕͋Δͱͳ͓Α͠ #!/bin/bash set -x ( sleep $(($RANDOM %
30)) && \ cat | jq -r .[-1].Payload | base64 -d > /var/lib/nginx_tls_session_ticket.key && \ systemctl reload nginx && echo reload OK ) || curl -d 'channel=#XXXX' -d "message=Failed reload: $(hostname)" notifier.local/notice
ࢀߟ $POTVMΛར༻ͨ͠5-4ηογϣϯνέοτͷ ࣗಈߋ৽ IUUQUFDINFSDBSJDPNFOUSZ
ྫDPMMFDUPS
DG7*1ʹΑΔՄ༻ੑͷ֬อ ͷαʔόͷલʹ7*1ΛׂΓৼΔྫ GPPVE[VSBKQ"
7*1ͷσϝϦοτ /த.ͷ*1Λάϩʔόϧ*1ͱ͚ͯͭ͠Δɺ ͱ͍͏͜ͱ͕͍͠ɻ %/4ϥϯυϩϏϯͱͷ૬ੑ͕ѱ͍ ͋ΔυϝΠϯ͕/ݸͷ*1Λ͍࣋ͬͯΔͱ͖ɺ ࣮αʔό/ݸҎ্ඞཁʹͳͬͯ͠·͏
͡Ό͋ಈతʹ %/4Λߋ৽ͯ͠Έͯʁ
None
DPMMFDUPSͷத ΫϥΠΞϯτ DPOTVMͷϔϧενΣοΫͰ͏ ίϯγϡʔϚʔ DPOTVMXBUDIͰ্ཱ͓ͪ͛ͯ͘
ϔϧενΣοΫʹߋ৽ͷͨΊͷ*1ΛؚΊΔ
DIFDLΛࢹͯ͠มߋΛऔಘ͢Δ check watch
ͦͷ༰͔Β%/4 3PVUF Λୟ͘ watch GPPVE[VSBKQ" GPPVE[VSBKQ" GPPVE[VSBKQ"
௨ػೳೖΕͯ·͢
ઃܭࢥ %/4ΩϟογϡͳͲʹΑΔҰ࣌తͳෆ௨ڐ༰ ར༻ͷ্Ͱɺ55-Λ͘͢Δ͖ සൟͳߋ৽ʹ͔ͳ͍
ৄࡉ ͬͯΈͯͶ IUUQTHJUIVCDPNVE[VSBDPMMFDUPS
·ͱΊ
$POTVM࣮γϯϓϧʂ
"*ͱ͕ؔͳ͍ ʜ
"*Λۦಈ͢ΔԿ͔͠Βͷج൫ʹ ͑Δ͔͠Εͳ͍͕ɺΞΠσΞ࣍ୈ
͝੩ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ
օ༷ͷΑ͏ͳ ༏लͳएऀΛͭ
ը૾ʹ͍ͭͯ ϑϦʔΞΠίϯ IUUQTDPNNPOTXJLJNFEJBPSHXJLJ'JMF4FSWFS NVMUJQMFTWH IUUQTDPNNPOTXJLJNFEJBPSHXJLJ 'JMF$PNQVUFSCMVFTWH
ͦͷଞɺϩΰɺΞΠίϯ֤ࣾɾஂମʹݖར͕͋Γ·͢ɻ Ҿ༻ͷൣғͰར༻͍ͯ͠·͢ɻ