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
710
Dockerとやわらかい仮想化 - ProSec-IT/SECKUN 2021 edition -
udzura
2
670
Device access filtering in cgroup v2
udzura
1
770
"Story of Rucy" on RubyKaigi takeout 2021
udzura
0
720
Other Decks in Technology
See All in Technology
TypeScript、上達の瞬間
sadnessojisan
46
13k
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
440
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
180
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
120
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
2
230
Platform Engineering for Software Developers and Architects
syntasso
1
520
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
OTelCol_TailSampling_and_SpanMetrics
gumamon
1
220
Application Development WG Intro at AppDeveloperCon
salaboy
0
200
Engineer Career Talk
lycorp_recruit_jp
0
190
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Six Lessons from altMBA
skipperchong
27
3.5k
Bash Introduction
62gerente
608
210k
The Language of Interfaces
destraynor
154
24k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
It's Worth the Effort
3n
183
27k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
RailsConf 2023
tenderlove
29
900
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
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
ͦͷଞɺϩΰɺΞΠίϯ֤ࣾɾஂମʹݖར͕͋Γ·͢ɻ Ҿ༻ͷൣғͰར༻͍ͯ͠·͢ɻ