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
'D'evelopment and 'D'eployment with 'D'ocker at...
Search
ixixi
January 17, 2015
Technology
15
32k
'D'evelopment and 'D'eployment with 'D'ocker at 'D'wango
Development with Docker,
Deployment with Docker.
ixixi
January 17, 2015
Tweet
Share
More Decks by ixixi
See All by ixixi
niconico超コメント生成ハッカソンレギュレーション
ixixi
1
200
Other Decks in Technology
See All in Technology
開発と脆弱性と脆弱性診断についての話
su3158
1
1.1k
7月のガバクラ利用料が高かったので調べてみた
techniczna
3
240
MySQL HeatWave:サービス概要のご紹介
oracle4engineer
PRO
4
1.7k
知られざるprops命名の慣習 アクション編
uhyo
10
2.4k
.NET開発者のためのAzureの概要
tomokusaba
0
230
認知戦の理解と、市民としての対抗策
hogehuga
0
310
Browser
recruitengineers
PRO
3
260
広島銀行におけるAWS活用の取り組みについて
masakimori
0
130
人を動かすことについて考える
ichimichi
2
320
実践アプリケーション設計 ①データモデルとドメインモデル
recruitengineers
PRO
2
200
見てわかるテスト駆動開発
recruitengineers
PRO
4
280
制約理論(ToC)入門
recruitengineers
PRO
2
250
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Invisible Side of Design
smashingmag
301
51k
Statistics for Hackers
jakevdp
799
220k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
Practical Orchestrator
shlominoach
190
11k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Documentation Writing (for coders)
carmenintech
73
5k
Visualization
eitanlees
147
16k
Producing Creativity
orderedlist
PRO
347
40k
Balancing Empowerment & Direction
lara
2
590
Transcript
Development and Deployment with Docker at Dwango @ixixi
%8"/(0$P -UE :VSJ0EBHJSJ !JYJYJ 3FDPNNFOEBUJPOTZTUFNBSDIJUFDU
Development with Docker
/JDPOJDP "QQMJDBUJPO4FSWFS )551SFRVFTU 8FC 4FSWFS $BTTBOESB 3FDPNNFOE "1*4FSWFS Recommendation API
3FDPNNFOE 4FSWFS 0UIFS4FSWJDFT MPHT $BDIF4FSWFS MPHT w%PDLFSҎલ͔ΒՔಇ͍ͯ͠ΔϨίϝϯυ"1* wχίχίಈըͷʮؔ࿈ಈըʯͳͲΛฦ͢ɻ
Ϩίϝϯυͷ֬ೝͱςετ wϨίϝϯυͷγεςϜʹखΛՃ͑ͨ߹ʹɺϨίϝϯυ݁Ռ͕Ͳ͏ มԽ͢Δ͔ͷ֬ೝɺίʔυϨϏϡʔɾ6OJU5FTUͰอূͮ͠Β͍ɻ ! wQVMMSFRΛNBTUFSʹऔΓࠐΉຊ൪σϓϩΠͳͷͰɺ֬ೝແ͠Ͱͷ ೖͨ͘͠ͳ͍ɻ ! wͲ͏ʹ͔ͯ͠ɺखܰʹʮ࣮ࡍͷڥΛ֬ೝʯग़དྷΔΑ͏ʹ͍ͨ͠ɻ
Γ͍ͨ͜ͱ wQVMMSFRग़ͨ͠ΒɺϨίϝϯυʹؔΘΔ%PDLFSͷ ίϯςφҰἧ͍ lܥz ͕উखʹཱͭɻ wࣗͰڥΛ࡞ͬͯࢼ͞ͳͯ͘ɺ ʮ͜͜Ͱطʹಈ͍͍ͯΔΑʯͱ͍͏ঢ়ଶ͕࠷ߴɻ ! wϨίϝϯυ"1*Ͱɺ࣮ࡍʹԿ͕Ϩίϝϯυ͞ΕΔ͔ දࣔग़དྷΔ3FDPNNFOE7JFXFS
෦πʔϧ Ͱݟ͍ͨɻ طʹಈ͍͍ͯΔ
/JDPOJDP "QQMJDBUJPO4FSWFS )551SFRVFTU 8FC 4FSWFS $BTTBOESB 3FDPNNFOE "1*4FSWFS Containerize! 3FDPNNFOE
4FSWFS 0UIFS4FSWJDFT MPHT $BDIF4FSWFS MPHT 3FDPNNFOE 7JFXFS )551SFRVFTU
pull request builderͰҰ্ཱࣜͪ͛&௨ wKFOLJOTͷQVMMSFRVFTUCVJMEFSΛར༻ɻ wKPCDIBJOͰςετ͔Βίϯςφ࡞ɺίϝϯτॻ͖ࠐΈ·Ͱ࣮ߦɻ QVMMSFRVFTUCVJMEFS QVMMSFRVFTU ௨ৗͷςετ QVMMSFRVFTUΛөͨ͠ EPDLFSίϯςφ࡞
EPDLFSίϯςφͰ ܥΛҰࣜىಈ ଓઌϙʔτใΛ QVMMSFRίϝϯτʹॻࠐ ίϝϯτʹॻ͖ࠐΈ
ίϯςφੜ wQVMMSFRVFTUʹରԠͨ͠ίϯςφ໊ͷQSFpYΛ࡞Δɻ wྫ QVMMSFR൪߸͕Ͱ࣌ࠁ͕ͳΒ ɹɹQVMMSFR@SFDPNNFOE@BQJ@@U wಉҰQVMMSFRͰɺߋ৽͞ΕΔʹίϯςφੜ͍ͨ͠ͷͰɺ͕࣌ඞཁɻ wQVMMSFRऴྃ࣌ ޙड़ ʹ͜ͷQSFpYΛར༻ɻ
ίϯςφͰʮܥʯΛཱͯΔ wHJUQVMM͔ͯ͠ΒpHCVJME͢ΔSBLFUBTLΛ࣮ߦ wQVMMSFRʹରԠͨ͠CSBODIΛͬͯCVJME͕Δɻ wΞϓϦߋ৽෦ҎલΩϟογϡ͕ޮ͘ͷͰCVJMEߴ ! wੜͨ͠QSFpYΛՃͨ͠ίϯςφ໊ͰpHVQ͢ΔSBLFUBTL࣮ߦ ! wDBTTBOESBSFEJTͷαʔόɺμϛʔσʔλ͕ ೖͬͨίϯςφ্ཱ͕͕ͪΔɻ !
wQVMMSFRͷίϝϯτͰɺىಈͤ͞Δ֤ίϯςφͷ CSBODIΛ໌ࣔࢦఆ͢Δ͜ͱՄೳɻ ผͷSFQPTJUPSZͷQVMMSFRҰॹʹద༻͢Δඞཁ͕͋Δ߹ $BTTBOESB 3FDPNNFE "1*4FSWFS 3FDPNNFOE 4FSWFS $BDIF 4FSWFS 3FDPNNFOE 7JFXFS MJOL MJOL MJOL MJOL
PullReqίϝϯτͷॻ͖ࠐΈ w֤ίϯςφׂ͕ΓͯΒΕͨϙʔτΛऔಘɻ ! wଓใΛ()FͷQVMMSFRίϝϯτʹॻ͘ɻ
Garbage Collection (daily) wQVMMSFRVFTU͕DMPTF͞ΕͨΒίϯςφΛࢭΊΔআ͢Δɻ wKFOLJOTͰQVMMSFRVFTUͷDMPTFIPPL͢Δ͜ͱ͕͔ͬͨͨ͠Ίɺ࣍Ͱ($ɻ DSPO wEPDLFSͷίϯςφ໊ͷQSFpYΛQBSTFͯ͠ɺSFQPTJUPSZͱQVMMSFRVFTU൪߸Λऔಘɻ w֘QVMMSFRVFTU͕DMPTF͞Ε͍ͯΔ͔֬ೝ͠ɺด͍ͯͨ͡Βίϯςφఀࢭআɻ !
wίϯςφ໊ͷQSFpYͰͳ͘FUDESFEJTʹରԠΛอ࣋ͯ͠ྑ͔͕ͬͨɺߏͷγϯϓ ϧ͞Λॏࢹɻ
developmentฤ Ή͢ͼ wطଘͷϓϩμΫτΛ%PDLFSԽ͢Δͷਏ͍߹͕͋ͬͨɻ wڥߏஙΛDIFGͰߦ͏લఏͷϓϩμΫτΛޙ͔Β%PDLFSԽ͢Δͷେมʹײͨ͡ɻ ! wطଘ෦Λ%PDLFSԽ͢ΔΑΓɺ৽نͰ࡞ΔͷΛ%PDLFSԽલఏͰߏங͢Δํ͕ྑ͍ɻ w1VMM3FRVFTUͰʮͦͷͰ࣮ࡍʹ৮ΕΔڥ͕طʹಈ͍͍ͯΔʯͷ࠷ߴɻ
Deployment with Docker
Personalize API /JDPOJDP "QQMJDBUJPO4FSWFS )551SFRVFTU 8FC 4FSWFS $BDIF %BUBCBTF 3FWFSTF
1SPYZ 1FSTPOBMJ[F"1* • ύʔιφϥΠζʹར༻͢ΔAPI (golang࣮) • DockerલఏͰ৽نʹߏஙɻ
Containerize! • ύʔιφϥΠζAPI • ϩάసૹ&ू(fluentd) • CEPΤϯδϯ(Norikra) • ϩάอଘ (ES&InfluxDB)
• ՄࢹԽ (Kibana&Grafana) • ϦόʔεϓϩΩγ 1FSTPOBMJ[F"1* /JDPOJDP "QQMJDBUJPO4FSWFS )551SFRVFTU $POUBJOFSJ[F 8FC 4FSWFS $BDIF %BUBCBTF MPHTUPSF .FUSJDT7JTVBMJ[FS $&1 -PH$PMMFDUPS 3FWFSTF 1SPYZ
Dataflow DP 4FSWFS )551SFRVFTU $BDIF %BUBCBTF MPHTUPSF .FUSJDT7JTVBMJ[FS $&1 3FWFSTF
1SPYZ -PBE #BMBODFS -PH"HHSFHBUPS MPHpMF %PDLFS)PTU %PDLFS)PTU %PDLFS)PTU %PDLFS)PTU "1* -PH $PMMFDUPS w ֤IPTUͷϦόʔεϓϩΩγ OHJOY ܦ༝Ͱ"1*ʹϦΫΤετɻ w ϩάϑΝΠϧϗετଆϘϦϡʔϜΛϚϯτͯ͠ॻ͖ग़͠ɻ w qVFOUEίϯςφଆͰϩάσΟϨΫτϦΛϚϯτͯ͠ɺಡΈࠐΈɻ w ϩάूίϯςφͰϩάΛूΊͯɺ$&1 /PSJLSB Ͱूܭͭͭ͠ʹอଘˠՄࢹԽ
Docker Build Architecture MPDBM ()F +FOLJOT 3FHJTUSZ $PNNPO QVTITPVSDFT )PPL
w %PDLFS*NBHFϏϧυ w ίϯςφͰܥΛ্ཱͪ͛ͯ݁߹ςετ w υΩϡϝϯτͷੜ w %PDLFS3FHJTUSZʹΠϝʔδొ "1* qVFOUE /HJOY SFHJTUFS"1*DPOUBJOFS*NBHF VCVOUV CVJMEͷىͱͳΔJNBHFɺ1SJWBUF SFHJTUSZʹஔ͍͓͖ͯɺ%PDLFSIVC SFHJTUSZͷར༻͠ͳ͍ɻ
Deploy Manager WebUI • WebUIσϓϩΠπʔϧ • DockerԽҎલ͔Β͍ͬͯͨπʔϧ • Capistrano task
࣮ߦ • Ϣʔβೝূ • σϓϩΠϩάͷϦΞϧλΠϜදࣔ&อଘ • DockerσϓϩΠcapistrano taskԽͯ͠ར༻ σϓϩΠઌαʔόΛબͯ͠ɺϙνοͱ 1click͚ͩͰແఀࢭσϓϩΠɻ • σϓϩΠͷrollbackλεΫ༻ҙɻ
Docker Deployment Architecture %FQMPZ.BOBHFS 8FC6* 3FHJTUSZ ڞ௨ 3FHJTUSZ QSPEVDUJPOઃఆ "1*
qVFOUE /HJOY "1*TFSWFSDPOpH 0QFSBUF QVMM qVFOUE 3FWFSTF1SPYZ "1* QVMM "1*TFSWFSDPOpH %PDLFS)PTU 0UIFS4FSWJDFT %FQMPZ $BQJTUSBOPUBTL )551SFRVFTU NPVOU • Capistrano taskͰɺίϯςφͷ ΠϝʔδΛ֤ϗετ͕pullͯ͠σϓϩΠɻ ! • ࣮ߦόΠφϦͷίϯςφΠϝʔδ։ൃऀ શһ͕pullՄೳɻ ! • productionڥͰ͏configίϯςφɺ registry͝ͱ(ೝূ͕ҟͳΔ)ɻ
Deployment ~ step.1 1.APIίϯςφΠϝʔδͱɺઃఆΠϝʔδ ΛɺDockerHostଆͰpull͢Δ %PDLFS)PTU 3FHJTUSZ ڞ௨ 3FHJTUSZ ઃఆ
"1* qVFOUE /HJOY "1*W EPDLFSJNBHFT "1*TFSWFSDPOpH "1*TFSWFSDPOpH "1*TFSWFS DPOpH NPVOU NPVOU 3FWFSTF1SPYZ "1*W qVFOUEMBUFTU
Deployment ~ step.1 1.APIίϯςφΠϝʔδͱɺઃఆΠϝʔδ ΛɺDockerHostଆͰpull͢Δ %PDLFS)PTU 3FHJTUSZ ڞ௨ 3FHJTUSZ ઃఆ
"1* qVFOUE /HJOY EPDLFSQVMMBQJMBUFTU EPDLFSQVMMBQJ@DPOpHMBUFTU "1*W EPDLFSJNBHFT "1*W MBUFTU "1*TFSWFSDPOpH "1*TFSWFSDPOpH "1*TFSWFS DPOpH NPVOU NPVOU 3FWFSTF1SPYZ "1*W qVFOUEMBUFTU
Deployment ~ step.2 1.৽͍͠imageͷίϯςφΛىಈ 2.API͕ਖ਼͘͠ϦΫΤετΛฦͤΔ·Ͱͭ ɹ(࣮ࡍʹϨεϙϯεΛ֬ೝ) %PDLFS)PTU "1*W qVFOUEMBUFTU DPOpH
3FWFSTF1SPYZ
Deployment ~ step.2 1.৽͍͠imageͷίϯςφΛىಈ 2.API͕ਖ਼͘͠ϦΫΤετΛฦͤΔ·Ͱͭ ɹ(࣮ࡍʹϨεϙϯεΛ֬ೝ) %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU
qVFOUEMBUFTU DPOpH DPOpH 3FWFSTF1SPYZ
Deployment ~ step.2 1.৽͍͠imageͷίϯςφΛىಈ 2.API͕ਖ਼͘͠ϦΫΤετΛฦͤΔ·Ͱͭ ɹ(࣮ࡍʹϨεϙϯεΛ֬ೝ) %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU
qVFOUEMBUFTU DPOpH DPOpH IFBMUIDIFDL EVNNZSFRVFTU 3FWFSTF1SPYZ
Deployment ~ step.3 1.৽͍͠IPΛnginxͷconfʹॻ͖ࠐΉɻ 2.NginxΛgraceful restartͯ͠ɺແఀࢭͰίϯςφ ͷ͚ઌΛมߋ͢Δɻ Reverse Proxy(nginx)ͷDockerίϯςφͰ 1.$
kill -USR2 `cat /var/run/nginx.pid` 2.$ kill -WINCH `cat /var/run/nginx.pid.oldbin` 3.$ kill -QUIT `cat /var/run/nginx.pid.oldbin` ※࣮ࡍʹɺgracefull restart෦ γΣϧεΫϦϓτԽͯ͠ɺίϯςφʹಉࠝɻ %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH DPOpH OHJOYDPOG OHJOY QPSU
Deployment ~ step.3 1.৽͍͠IPΛnginxͷconfʹॻ͖ࠐΉɻ 2.NginxΛgraceful restartͯ͠ɺແఀࢭͰίϯςφ ͷ͚ઌΛมߋ͢Δɻ Reverse Proxy(nginx)ͷDockerίϯςφͰ 1.$
kill -USR2 `cat /var/run/nginx.pid` 2.$ kill -WINCH `cat /var/run/nginx.pid.oldbin` 3.$ kill -QUIT `cat /var/run/nginx.pid.oldbin` ※࣮ࡍʹɺgracefull restart෦ γΣϧεΫϦϓτԽͯ͠ɺίϯςφʹಉࠝɻ %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH DPOpH OHJOYDPOG MPDBUJPO\ QSPYZ@QBTTIUUQ ^ OHJOY QPSU
Deployment ~ step.3 1.৽͍͠IPΛnginxͷconfʹॻ͖ࠐΉɻ 2.NginxΛgraceful restartͯ͠ɺແఀࢭͰίϯςφ ͷ͚ઌΛมߋ͢Δɻ Reverse Proxy(nginx)ͷDockerίϯςφͰ 1.$
kill -USR2 `cat /var/run/nginx.pid` 2.$ kill -WINCH `cat /var/run/nginx.pid.oldbin` 3.$ kill -QUIT `cat /var/run/nginx.pid.oldbin` ※࣮ࡍʹɺgracefull restart෦ γΣϧεΫϦϓτԽͯ͠ɺίϯςφʹಉࠝɻ %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH DPOpH OHJOYDPOG MPDBUJPO\ QSPYZ@QBTTIUUQ ^ MPDBUJPO\ QSPYZ@QBTTIUUQ ^ OHJOY QPSU
Deployment ~ step.3 1.৽͍͠IPΛnginxͷconfʹॻ͖ࠐΉɻ 2.NginxΛgraceful restartͯ͠ɺແఀࢭͰίϯςφ ͷ͚ઌΛมߋ͢Δɻ Reverse Proxy(nginx)ͷDockerίϯςφͰ 1.$
kill -USR2 `cat /var/run/nginx.pid` 2.$ kill -WINCH `cat /var/run/nginx.pid.oldbin` 3.$ kill -QUIT `cat /var/run/nginx.pid.oldbin` ※࣮ࡍʹɺgracefull restart෦ γΣϧεΫϦϓτԽͯ͠ɺίϯςφʹಉࠝɻ %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH DPOpH OHJOYDPOG OHJOY QPSU
Deployment ~ step.3 1.৽͍͠IPΛnginxͷconfʹॻ͖ࠐΉɻ 2.NginxΛgraceful restartͯ͠ɺແఀࢭͰίϯςφ ͷ͚ઌΛมߋ͢Δɻ Reverse Proxy(nginx)ͷDockerίϯςφͰ 1.$
kill -USR2 `cat /var/run/nginx.pid` 2.$ kill -WINCH `cat /var/run/nginx.pid.oldbin` 3.$ kill -QUIT `cat /var/run/nginx.pid.oldbin` ※࣮ࡍʹɺgracefull restart෦ γΣϧεΫϦϓτԽͯ͠ɺίϯςφʹಉࠝɻ %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH DPOpH OHJOYDPOG OHJOY OHJOY QPSU
Deployment ~ step.3 1.৽͍͠IPΛnginxͷconfʹॻ͖ࠐΉɻ 2.NginxΛgraceful restartͯ͠ɺແఀࢭͰίϯςφ ͷ͚ઌΛมߋ͢Δɻ Reverse Proxy(nginx)ͷDockerίϯςφͰ 1.$
kill -USR2 `cat /var/run/nginx.pid` 2.$ kill -WINCH `cat /var/run/nginx.pid.oldbin` 3.$ kill -QUIT `cat /var/run/nginx.pid.oldbin` ※࣮ࡍʹɺgracefull restart෦ γΣϧεΫϦϓτԽͯ͠ɺίϯςφʹಉࠝɻ %PDLFS)PTU "1*W "1*W qVFOUEMBUFTU qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH DPOpH OHJOYDPOG OHJOY QPSU
Deployment ~ step.4 1.ݹ͍ίϯςφͷఀࢭ&আ 2.ݹ͍ίϯςφΠϝʔδͷআ ˞ߴʹrollbackग़དྷΔΑ͏ɺ࣮ࡍʹ ɹ5ੈલͷΠϝʔδΛআ %PDLFS)PTU "1*W
"1*W qVFOUEMBUFTU qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH DPOpH OHJOY "1*W EPDLFSJNBHFT "1*W MBUFTU "1*TFSWFSDPOpH
Deployment ~ step.4 1.ݹ͍ίϯςφͷఀࢭ&আ 2.ݹ͍ίϯςφΠϝʔδͷআ ˞ߴʹrollbackग़དྷΔΑ͏ɺ࣮ࡍʹ ɹ5ੈલͷΠϝʔδΛআ %PDLFS)PTU "1*W
qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH OHJOY "1*W EPDLFSJNBHFT "1*W MBUFTU "1*TFSWFSDPOpH
Deployment ~ step.4 1.ݹ͍ίϯςφͷఀࢭ&আ 2.ݹ͍ίϯςφΠϝʔδͷআ ˞ߴʹrollbackग़དྷΔΑ͏ɺ࣮ࡍʹ ɹ5ੈલͷΠϝʔδΛআ %PDLFS)PTU "1*W
qVFOUEMBUFTU 3FWFSTF1SPYZ DPOpH OHJOY EPDLFSJNBHFT "1*W MBUFTU "1*TFSWFSDPOpH
deploymentฤ Ή͢ͼ wμϯλΠϜແ͠ͷσϓϩΠՄೳ͕ͩɺݱঢ়ɺࣗલͰগ͠࡞Γ͜Ήඞཁ͕͋Δɻ wࣗલͷίϯςφସલϔϧενΣοΫɻ ! wϗετଆͷڥ͕ԚΕͳ͍ͷૉΒ͍͠ɻ ! wظӡ༻͢ΔલఏͳΒΰϛΛย͚ΔػߏΛ࣋ͱ͏ɻ wLTΛ͏ʹɺNBTUFSͷԽߴՄ༻ੑͳFUDEΫϥελͷߏஙɾӡ༻ɺ نͷׂʹ߹Θͳ͔ͬͨͷͰʮϦιʔεͷநԽʯ·Ͱ౿Έࠐ·ͳͳ͔ͬͨɻ
wαʔϏεԣஅͰར༻ՄೳͳେنσϓϩΠઌαʔόࢿݯͱͯ͠நԽ͢Δ߹ʹɺ LT͕ඞཁʹͳΔͱࢥ͏ɻنͱతʹԠͯ͡ΞʔΩςΫνϟઃܭ͠Α͏ɻ
υϫϯΰࠂ ͜ͷهࣄυϫϯΰۈ࣌ؒதʹॻ͔Εͨɻ ! υϫϯΰຊͷ (C++|Elrang|ݕࡧ|Ϩίϝϯυ|σʔλੳ|σʔλ࿈ܞ|FPGA|Πϯϑϥ|WEBΞϓϦ) ΤϯδχΞΛืू͍ͯ͠·͢ɻ ࠾༻ใ | גࣜձࣾυϫϯΰ