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
210
Narrative of Ruby & Rust
udzura
0
180
開発者生産性指標の可視化 / pepabo-four-keys
udzura
3
1.6k
Talk of RBS
udzura
0
400
Re: みなさん最近どうですか? / FGN tech meetup in 2021
udzura
0
720
Dockerとやわらかい仮想化 - ProSec-IT/SECKUN 2021 edition -
udzura
2
690
Device access filtering in cgroup v2
udzura
1
800
"Story of Rucy" on RubyKaigi takeout 2021
udzura
0
750
Other Decks in Technology
See All in Technology
Formal Development of Operating Systems in Rust
riru
1
420
The future we create with our own MVV
matsukurou
0
2k
完全自律型AIエージェントとAgentic Workflow〜ワークフロー構築という現実解
pharma_x_tech
0
330
WantedlyでのKotlin Multiplatformの導入と課題 / Kotlin Multiplatform Implementation and Challenges at Wantedly
kubode
0
240
Kotlin Multiplatformのポテンシャル
recruitengineers
PRO
2
150
チームが毎日小さな変化と適応を続けたら1年間でスケール可能なアジャイルチームができた話 / Building a Scalable Agile Team
kakehashi
2
230
Amazon Q Developerで.NET Frameworkプロジェクトをモダナイズしてみた
kenichirokimura
1
190
iPadOS18でフローティングタブバーを解除してみた
sansantech
PRO
1
130
AWSサービスアップデート 2024/12 Part3
nrinetcom
PRO
0
140
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
120
Azureの開発で辛いところ
re3turn
0
240
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
170
14k
Statistics for Hackers
jakevdp
797
220k
Optimising Largest Contentful Paint
csswizardry
33
3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Designing for Performance
lara
604
68k
How to Ace a Technical Interview
jacobian
276
23k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Making the Leap to Tech Lead
cromwellryan
133
9k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
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
ͦͷଞɺϩΰɺΞΠίϯ֤ࣾɾஂମʹݖར͕͋Γ·͢ɻ Ҿ༻ͷൣғͰར༻͍ͯ͠·͢ɻ