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
200
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
680
Device access filtering in cgroup v2
udzura
1
780
"Story of Rucy" on RubyKaigi takeout 2021
udzura
0
730
Other Decks in Technology
See All in Technology
なぜCodeceptJSを選んだか
goataka
0
160
Qiita埋め込み用スライド
naoki_0531
0
5.1k
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
850
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
880
5分でわかるDuckDB
chanyou0311
10
3.2k
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
2
190
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
19
18k
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
180
2024年にチャレンジしたことを振り返るぞ
mitchan
0
140
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Statistics for Hackers
jakevdp
796
220k
Mobile First: as difficult as doing things right
swwweet
222
9k
Building Applications with DynamoDB
mza
91
6.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Writing Fast Ruby
sferik
628
61k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Building an army of robots
kneath
302
44k
It's Worth the Effort
3n
183
28k
Faster Mobile Websites
deanohume
305
30k
Building Your Own Lightsaber
phodgson
103
6.1k
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
ͦͷଞɺϩΰɺΞΠίϯ֤ࣾɾஂମʹݖར͕͋Γ·͢ɻ Ҿ༻ͷൣғͰར༻͍ͯ͠·͢ɻ