Upgrade to Pro — share decks privately, control downloads, hide ads and more …

'D'evelopment and 'D'eployment with 'D'ocker at...

ixixi
January 17, 2015

'D'evelopment and 'D'eployment with 'D'ocker at 'D'wango

Development with Docker,
Deployment with Docker.

ixixi

January 17, 2015
Tweet

More Decks by ixixi

Other Decks in Technology

Transcript

  1. /JDPOJDP "QQMJDBUJPO4FSWFS )551SFRVFTU 8FC 4FSWFS $BTTBOESB 3FDPNNFOE
 "1*4FSWFS Recommendation API

    3FDPNNFOE 4FSWFS 0UIFS4FSWJDFT MPHT $BDIF4FSWFS MPHT w%PDLFSҎલ͔ΒՔಇ͍ͯ͠ΔϨίϝϯυ"1* wχίχίಈըͷʮؔ࿈ಈըʯͳͲΛฦ͢ɻ
  2. /JDPOJDP "QQMJDBUJPO4FSWFS )551SFRVFTU 8FC 4FSWFS $BTTBOESB 3FDPNNFOE
 "1*4FSWFS Containerize! 3FDPNNFOE

    4FSWFS 0UIFS4FSWJDFT MPHT $BDIF4FSWFS MPHT 3FDPNNFOE 7JFXFS )551SFRVFTU
  3. ίϯςφͰʮܥʯΛཱͯΔ 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
  4. Personalize API /JDPOJDP "QQMJDBUJPO4FSWFS )551SFRVFTU 8FC 4FSWFS $BDIF %BUBCBTF 3FWFSTF

    1SPYZ 1FSTPOBMJ[F"1* • ύʔιφϥΠζʹར༻͢ΔAPI (golang࣮૷) • DockerલఏͰ৽نʹߏஙɻ
  5. 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
  6. 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 Ͱूܭͭͭ͠ʹอଘˠՄࢹԽ
  7. 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ͷ౎౓ར༻͸͠ͳ͍ɻ
  8. Deploy Manager WebUI • WebUIσϓϩΠπʔϧ • DockerԽҎલ͔Β࢖͍ͬͯͨ಺੡πʔϧ • Capistrano task

    ࣮ߦ • Ϣʔβೝূ • σϓϩΠϩάͷϦΞϧλΠϜදࣔ&อଘ
 • DockerσϓϩΠ΋capistrano taskԽͯ͠ར༻
 σϓϩΠઌαʔόΛબ୒ͯ͠ɺϙνοͱ
 1click͚ͩͰແఀࢭσϓϩΠɻ • σϓϩΠͷrollbackλεΫ΋༻ҙɻ
  9. 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͝ͱ෼཭(ೝূ͕ҟͳΔ)ɻ
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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