Kubernetesとツール開発 / #chibadan

Bc1e4b3a33fe6718f50285d1c1f53feb?s=47 Kodai Sakabe
October 25, 2016

Kubernetesとツール開発 / #chibadan

全社で Kubernetes を利用していくための取り組みと Kubernetes の便利な機能について話をしました

Bc1e4b3a33fe6718f50285d1c1f53feb?s=128

Kodai Sakabe

October 25, 2016
Tweet

Transcript

  1. ,PEBJ4BLBCF!LPVEBJJJ8BOUFEMZ *OD ,VCFSOFUFTͱπʔϧ։ൃ αʔϏε։ൃͷݱ৔ΛޠΔʂ .JDSPTFSWJDFT LVCFSOFUFT ଞ

  2. ABOUT ME — Software Engineer — 2010/4- TIS ࡔ෦ ޿େ

    (KOUDAI SAKABE) 2015/8- Wantedly @koudaiii Site: http://koudaiii.com
  3. WANTEDLY — γΰτͰίίϩΦυϧͻͱΛ;΍͢—

  4. 1SPEVDUJWJUZ w ʮςετ͔Βݟ͑ͯ͘Δάʔάϧͷιϑτ΢ΣΞ։ൃʯ w ΤϯδχΞϦϯάϓϩμΫςΟϏςΟνʔϜ w ੜ࢈ੑͷ޲্ w ͋Γͱ͋ΒΏΔ΋ͷΛߏங͢ΔπʔϧνʔϜ ςετ͔Βݟ͑ͯ͘Δάʔάϧͷιϑτ΢ΣΞ։ൃIUUQTXXXBNB[PODPKQEQ#*&#

  5. #PUUMFOFDL ΤϯδχΞͷ૿ՃɺαʔϏεͷ૿Ճ Developer ΠϯϑϥνʔϜ λεΫґཔ WANTEDLY JOURNAL ͸ͨΒ͘Λ໘ന͘͢ΔϝσΟΞ ੈքʹࣗ෼ͷ੠Λൃ৴͠Α͏

  6. ηϧϑαʔϏε w ΠϯϑϥΛૢ࡞͢Δ5PPMࣾ಺Ͱศརͳ$-*(6* Developer ΠϯϑϥνʔϜ API and Tool WANTEDLY JOURNAL

    ͸ͨΒ͘Λ໘ന͘͢ΔϝσΟΞ ੈքʹࣗ෼ͷ੠Λൃ৴͠Α͏
  7. ͜Ε·ͰͷऔΓ૊Έ w %PDLFSɺ"84ɺ%/4JNQMFΛૢ࡞Ͱ͖ΔXBOUFEMZDBQ w $* XFSDLFS ͷ݁ՌΛऔಘͰ͖ΔXLXL w %#ͷ4DIFNF͔Β(Pͷ"1*Λੜ੒Ͱ͖ΔXBOUFEMZBQJHXBOUFEMZQRHPSN w

    "1*ʹೝূ΍εϩοτϧͳͲΛϒϥ΢βͰઃఆͰ͖ΔXBOUFEMZLPOHGSPOUFOE w αʔϏεʹඞཁͳTZTUFNEͷTFSWJDFΛొ࿥Ͱ͖ΔDFMM w "84%/4JNQMF%BUB%PHΛૢ࡞Ͱ͖ΔEUBOUFSSBGPSNJOHXBOUFEMZUFSSBGPSN w ϑΝΠϧΛؾܰʹڞ༗Ͱ͖ΔEUBOTVSM w &$ͷNFUBUBHΛऔಘͨ͠Γૢ࡞Ͱ͖ΔEUBOFDD
  8. $ s3url —help #ظݶ෇͖URLΛൃߦ Usage of s3url: s3url https://s3-region.amazonaws.com/BUCKET/KEY [-d

    DURATION] s3url s3://BUCKET/KEY [-d DURATION] s3url -b BUCKET -k KEY [-d DURATION] $ ec2c —help # vagrant Ͱࢼͨ͠΋ͷΛ instance ͰݐͯΔ / tag Λ෇͚ΕΔ / ip Λ֬ೝͰ͖Δ Available commands are: launch Launch new EC2 instance list List EC2 instances tag Tag EC2 instances terminate Terminate the specified EC2 instance untag Tag EC2 instances FYTVSMFDD
  9. Πϯϑϥͷ௕ظతͳํ޲ੑ

  10. ࠷ۙͷऔΓ૊Έ,VCFSOFUFT ΠϯϑϥνʔϜ͸Ϋϥελͷج൫࡞Γͱπʔϧʹूத Web Application Monitoring Logging Auto Scale Load Balancer

    Internal DNS Web Application Monitoring Logging Auto Scale Load Balancer Internal DNS Web Application Monitoring Logging Auto Scale Load Balancer Internal DNS Monitoring Logging Auto Scale Load Balancer Internal DNS ΠϯϑϥνʔϜ ΠϯϑϥνʔϜ ΠϯϑϥνʔϜ ΠϯϑϥνʔϜ ґཔ͕͖ͨΒΠϯϑϥνʔϜ͸౎౓ߏ੒Λ͔Β࡞Δ
  11. .FSHF%FQMPZ

  12. $*EFQMPZ EPDLFSJNBHFUBHΛੜ੒ͯ͠SFHJTUSZQVTIͯ͠ɺ3PMMJOH6QEBUF

  13. ϞχλϦϯά ΠϯϑϥνʔϜ͸Ϋϥελͷج൫࡞Γͱπʔϧʹूத Web Application Monitoring Logging Auto Scale Load Balancer

    Internal DNS Web Application Monitoring Logging Auto Scale Load Balancer Internal DNS Web Application Monitoring Logging Auto Scale Load Balancer Internal DNS Monitoring Logging Auto Scale Load Balancer Internal DNS ΠϯϑϥνʔϜ ΠϯϑϥνʔϜ ΠϯϑϥνʔϜ ΠϯϑϥνʔϜ ґཔ͕͖ͨΒΠϯϑϥνʔϜ͸౎౓ߏ੒Λ͔Β࡞Δ
  14. %BTICPBSE TDPQFQPESDSDOBNFTQBDFͰߜΓࠐΈ"MFSUઃఆ %FWFMPQFSʹ͸%BTICPBSE͕ݟΕΔ͜ͱΛ஌ΒͤΔͷΈ

  15. ϞχλϦϯά %BFNPO4FUΛ࢖ͬͯ༧Ίઃఆ

  16. 4DIFEVMFE+PC CFUB$SPO+PC ࣌ؒࢦఆͰ࣮ߦͰ͖Δ BMQIB൛ɻ$SPO+PCʹ୅ΘΔ༧ఆ SFGIUUQTHJUIVCDPNLVCFSOFUFTLVCFSOFUFTJTTVFT

  17. )PXUP4DIFEVMFE+PC $ kubectl create -f examples/scheduled-job/hello-job.yaml scheduledjob "hello" created $

    kubectl get scheduledjob NAME SCHEDULE SUSPEND ACTIVE LAST-SCHEDULE hello 0/1 * * * ? False 0 Fri, 07 Oct 2016 17:23:00 +0900 hello-run 0/1 * * * ? False 0 <none> $ pods=$(kubectl get pods --selector=job-name=hello-1628211009 -- output=jsonpath={.items..metadata.name}) $ echo $pods hello-1628211009-d939p $ kubectl logs $pods Fri Oct 7 08:24:08 UTC 2016 Hello from the Kubernetes cluster
  18. 4DIFEVMFE+PC w ,VCFSOFUFTҎ্ w BMQIB൛ͷBQJTFSWFSʹରͯ͠ΦϓγϣϯΛ෇͚ΔAŠSVOUJNFDPOpHCBUDIWBMQIBA w +PCʹ͸3FTUBSU1PMJDZΛ෇͚Δ͜ͱ͕Ͱ͖ΔɻA0O'BJMVSFAPSA/FWFSA w FYίϯςφ͕GBJMVSFͷ৔߹ w

    &7&/5-PHʹGBJMVSF͕ॻ͖ࠐ·ΕΔ w *G3FTUBSU1PMJDZ w 0O'BJMVSFDPOUBJOFS͕࠶ىಈͯ͠+PCΛଓ͚Δ w /FWFSͦͷ··'BJMFEʹͳΔ
  19. 4DIFEVMFE+PC w Ұݸͣͭͷ+PCͷMPH͕ݟ΍͍͢ w ίϯςφͷΠϕϯτϨϕϧͰMPH͕औΕΔͷͰͦ΋ͦ΋ίϯςφ͕ىಈ ͠ͳ͔ͬͨͱ͖ͷݪҼௐ͕ࠪͰ͖Δ w ΫϥελϦϯάͷதͰ࣮ߦ͞ΕΔͷͰ,VCFSOFUFT͕ۭ͍͍ͯΔϦιʔ εʹର࣮ͯ͠ߦͯ͘͠ΕΔͷͰDSPO౳ͷҰͭͷΠϯελϯεʹറΒΕͳ ͍

  20. )PPL&WFOU w 1PTU4UBSU w ίϯςφ্ཱ͕͕ͪͬͨ௚ޙʹ࣮ߦ w 1SF4UPQ w ίϯςφ͕UFSNJOBUF͢Δ௚લʹ࣮ߦ SFGIUUQXXXDMPVEXFSLTUBUUDPNXQDPOUFOUVQMPBET10%QSFQPTU)00,QOH

  21. QPTU4UBSU IUUQTHJUIVCDPNLVCFSOFUFTLVCFSOFUFTCMPCNBTUFSFYBNQMFT KBWBXFCUPNDBUTJEFDBS3&"%.&NE

  22. QPTU4UBSU FYىಈͨ͠λΠϛϯάͰXBSϑΝΠϧΛWPMVNF.PVOUTʹ഑ஔ IUUQTUBDLPWFSqPXDPNRVFTUJPOTNVMUJQMFDPNNBOEJOQPTUTUBSUIPPLPGBDPOUBJOFS ͜Μͳ͜ͱ΋ग़དྷΔΒ͍͠

  23. QSF4UPQ (SBDFGVMMZ5FSNJOBUF ͦΕҎ֎ͷ࢖͍ํΛ͢Δͱ&WFOUMPHͱ͔LVCFDUMMPHTͰ֬ೝग़དྷͳ͍

  24. MJWFOFTT1SPCFIFBMUIDIFDL༻ 1SPCF\JOJUJBM%FMBZ4FDPOETԿඵޙʹ։࢝ UJNFPVU4FDPOETϨεϙϯεΛԿඵ଴ͭ TVDDFTT5ISFTIPME੒ޭճ਺ GBJMVSF5ISFTIPMEࣦഊճ਺ QFSJPE4FDPOETνΣοΫε͢Δִؒ^ IUUQTHJUIVCDPNLVCFSOFUFTLVCFSOFUFTCMPCNBTUFSDMVTUFSHDFDPSFPTLVCFNBOJGFTUTBEEPOTEOTTLZEOTSDZBNM

  25. SFBEJOFTT1SPCFτϥϑΟοΫΛड͚ΔλΠϛϯά TLZEOTSDZBNM͸MJWFOFTT1SPCFͱSFBEJOFTT1SPCFͷ྆ํΛ࢖͍ͬͯ ΔͷͰΞϓϦέʔγϣϯͷཁ݅ʹԠͯ͡ࢀߟʹग़དྷΔ IUUQTHJUIVCDPNLVCFSOFUFTLVCFSOFUFTCMPCNBTUFSDMVTUFSHDFDPSFPTLVCFNBOJGFTUTBEEPOTEOTTLZEOTSDZBNM

  26. ,VCFSOFUFT "84&$$POUBJOFS3FHJTUSZ &$3 *".SPMFʹ෇༩͢Ε͹ɺͦͷ··࢖͑Δ FYLVCFSVOJUUZUFNQJNBHF"$$06/5ELSFDS3&(*0/BNB[POBXTDPN TBNQMFWDPNNBOECJOCBTI

  27. ֤νʔϜͰ࢖ͬͯ΋Β͏ͨΊʹ

  28. πʔϧͷϕʔεͱͳΔ෦෼ΛܾΊΔ w ͳΔ΂͘ߋ৽͠΍͍͢ߏ੒ w ΫϥΠΞϯτଆʹ͸ग़དྷΔݶΓϩδοΫΛೖΕͳ͍ w ΫϥΠΞϯτଆͰ͍ͭωοτ͕੾ΕΔ͔Θ͔Βͳ͍͜ͱΛ૝ఆ͢Δ w ΫϥΠΞϯτଆʹେࣄͳ৘ใΛஔ͔ͳ͍ w

    ͳΔ΂͘όʔδϣϯΛࡉ্͔͛͘ΔৗʹΈΜͳ͕ۙ͘ʹ͍Δͱ͸ݶΒͳ͍ w ࠷௿ݶར༻Ͱ͖Δঢ়ଶ͔Β࢖ͬͯ΋Β͏ w खؒͩͱࢥ͏෦෼͔Βศརʹ͍ͯ͘͠
  29. FYŠOBNFTQBDFΛγϣʔτΧοτ͢Δ

  30. 5IF6/*9QIJMPTPQIZ w 4NBMMJTCFBVUJGVMখ͍͞΋ͷ͸ඒ͍͠ w .BLFFBDIQSPHSBNEPPOFUIJOHXFMMͭͷϓϩάϥϜʹ͸ͭͷ͜ͱΛ͏· ͘΍ΒͤΔ w $IPPTFQPSUBCJMJUZPWFSF⒏DJFODZޮ཰ΑΓҠ২ੑΛ༏ઌ͢Δ w 6TFTPGUXBSFMFWFSBHFUPZPVSBEWBOUBHFιϑτ΢ΣΞΛᑏࢠ

    ͯ͜ ͱͯ͠ ࢖͏ w "WPJEDBQUJWFVTFSJOUFSGBDFTա౉ͷର࿩తΠϯλʔϑΣʔεΛආ͚Δ
  31. LVCFSOFUFTΛૢ࡞Ͱ͖Δ$-* LVCFίϚϯυ Kubernetes for Wantedly kube Commands: • kube deploy

    • kube migration • kube diff • kube rollback • kube enable dotenv • kube enable private-repogitory quay • kube generate • kube tags • kube (kubectl subcommands) Container Tools: • kubectl • k8sec • slack notification(kubenotification) • deploy (kubeloy) • scheduler (?????) • ps/status (kubeps) Developer kube Server Kubernetes
  32. πʔϧͷ௥Ճ αʔόʔଆͰEPDLFSDPNQPTFZNMΛ௥ه͢Ε͹୭Ͱ΋ར༻Մೳ

  33. ΫϥΠΞϯτଆʹ͸TVCDPNNBOEͱͯ͠௥Ճ ˞ਖ਼ࣜϦϦʔε͢ΔࡍʹΫϥΠΞϯτଆΛ։์͢Δ

  34. ࣮ࡍߦ͖ͬͯͨखॱ ඞཁͩͱࢥ͏෦෼ΛܾΊΔ ࣾ಺ώΞϦϯά ͱ͔ΒϩʔυϚοϓʹམͱ͢ ͜͏͢Δͱ໰͍߹Θ͕ͤདྷͨ࣌ʹύοͱ౴͑ΕΔ  ίʔυ υοΫϑʔυ͢Δ ΞʔϦʔΞμϓλʔʹϓϨϦϦʔε ΞʔϦʔΞμϓλʔʹΞφ΢ϯεϋϯζΦϯ

    ϑΟʔυόοΫྑ͚Ε͹શମΞφ΢ϯε
  35. ϩʔυϚοϓ w CFUB൛Λҭ͍ͯͯ͘ํ਑ w ίϯηϓτΛܾΊΔ ମݧΛܾΊΔ  w ͬ͘͟Γͱͨ͠εέδϡʔϧ

  36. ·ͩ·ͩվળ͸ଓ͘ɻɻ &EJUPS໰୊ UPPMΛ࡞Δ͜ͱͰຊདྷى͜Βͳ͔ͬͨ͸ͣͷ໰୊΋͋Δ ͜͏͍͏ମݧ෦෼͸௚͙ʹվળ

  37. NEXT — ڵຯΛ࣋ͬͨํ͸ؾܰʹ࠙਌ձͰ࿩͠·͠ΐ͏!! —