Docker/Kubernetes社内勉強会#1 公開資料 / Study basic of Docker and Kubernetes

Ad22fcf5773b906c08330f4d57242212?s=47 Kohei Ota
August 16, 2019

Docker/Kubernetes社内勉強会#1 公開資料 / Study basic of Docker and Kubernetes

Ad22fcf5773b906c08330f4d57242212?s=128

Kohei Ota

August 16, 2019
Tweet

Transcript

  1. ࣾ಺๭ϓϩδΣΫτ ษڧձ  %PDLFS,VCFSOFUFT͜ͱ͸͡Ί ࣾ಺๭ϓϩδΣΫτ ษڧձ   גࣜձࣾ;0;0ςΫϊϩδʔζ ։ൃ෦

    .-0QTνʔϜ ଠా ߤฏ $PQZSJHIU˜;0;05FDIOPMPHJFT *OD
  2. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͷ͓͞Β͍ ˔%PDLFSίϯςφͱ%PDLFSΠϝʔδ ˔%PDLFSͰղܾͰ͖Δ͜ͱɾղܾͰ͖ͳ͍͜ͱ ˔ίϯςφɾΦʔέετϨʔγϣϯͷجૅ ˔,VCFSOFUFTͷΞʔΩςΫνϟ֓ཁ ΞδΣϯμ 2

  3. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͷ͓͞Β͍ ˔%PDLFSίϯςφͱ%PDLFSΠϝʔδ ˔%PDLFSͰղܾͰ͖Δ͜ͱɾղܾͰ͖ͳ͍͜ͱ ˔ίϯςφɾΦʔέετϨʔγϣϯͷجૅ ˔,VCFSOFUFTͷΞʔΩςΫνϟ֓ཁ ΞδΣϯμ 3

  4. ˜;0;05FDIOPMPHJFT *OD ˔EPU$MPVEࣾ %PDLFSࣾͷલ਎ ͕ࣗࣾͷ1BB4 1MBUGPSN BTB4FSWJDF Λ࡞ΔͨΊʹ։ൃͨ͠ίϯςφܕԾ૝Խ ͷΞϓϦέʔγϣϯ࣮ߦج൫ ˔طଘͷ7.ܕԾ૝Խʹൺ΂ɺىಈ͕ඇৗʹߴ଎

    %PDLFSͷ͓͞Β͍ 4
  5. ˜;0;05FDIOPMPHJFT *OD ˔ίϯςφܕԾ૝Խʁ ˓ίϯςφͱ͸ ˙ΞϓϦέʔγϣϯͷ࣮ߦʹඞཁͳ؀ڥΛ Ұͭͷύοέʔδʹ·ͱΊͨԾ૝తͳ୯Ґ ˔04ΑΓ΋ԼͷϨΠϠΛʮ-JOVYΧʔωϧʯΛ࢖ͬͯ ࠶ݱ͢ΔԾ૝Խٕज़ %PDLFSͷ͓͞Β͍ 5

      (Go/Java/Ruby...)   
  6. ˜;0;05FDIOPMPHJFT *OD -JOVY,FSOFM %PDLFS&OHJOF JT ! 6

  7. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͷ͓͞Β͍ ˔%PDLFSίϯςφͱ%PDLFSΠϝʔδ ˔%PDLFSͰղܾͰ͖Δ͜ͱɾղܾͰ͖ͳ͍͜ͱ ˔ίϯςφΦʔέετϨʔγϣϯͷجૅ ˔,VCFSOFUFTͷΞʔΩςΫνϟ֓ཁ ΞδΣϯμ 7

  8. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFS্Ͱʮ͜͏͍͏ৼΔ෣͍Λ͢Δʯͱ͍͏ఆٛ ˔%PDLFSGJMFΛॻ͘ˠϏϧυ͢Δ %PDLFSΠϝʔδ ˓࣮ଶ͸UBSܗࣜͰ·ͱΊͨΞʔΧΠϒϑΝΠϧ ˔͜ͷ࣌఺Ͱ͸·࣮ͩࡍʹಈ࡞͍ͯ͠ΔΘ͚Ͱ͸ͳ͍ %PDLFSΠϝʔδͱ͸ 8 Dockerfile

    docker build Docker
  9. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSϗετͷ্Ͱ࣮ࡍʹಈ࡞͢Δϓϩηε ˔ίϯςφΛ্ཱͪ͛ΔͨΊʹ͸ɺϕʔεͱͳΔ %PDLFSΠϝʔδ͕ඞཁ %PDLFSίϯςφͱ͸ 9 Docker  Docker

     Docker   Docker  docker run
  10. ˜;0;05FDIOPMPHJFT *OD ˔ݴ͍׵͑ΔͱɺԼهΛ࣮ߦͨ͠΋ͷ͕ίϯςφʹͳΔ ˓%PDLFSGJMF͔Β࡞੒ͨ͠खݩͷΠϝʔδ ˓࡞੒ࡁΈͷ֎෦ΠϝʔδΛϨδετϦ͔Βऔಘ %PDLFSίϯςφͱ͸ 10 Docker  Docker

     Docker   Docker  docker run
  11. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSGJMF͔ΒΠϝʔδΛϏϧυ ˔Ϗϧυͨ͠ΠϝʔδΛϨδετϦʹ1VTI ˔ಈ͔͍ͨ͠؀ڥͰΠϝʔδΛ1VMM͠ɺίϯςφΛىಈ ˔͜ͷྲྀΕΛ·ͱΊͯʮ#VJME 4IBSF 3VOʯͱݺͿ #VJME 4IBSF

    3VO 11 Dockerfile docker build Docker Docker docker run
  12. ˜;0;05FDIOPMPHJFT *OD %PDLFSΠϝʔδ͕ͦͷ·· ʮΰʔϧσϯΠϝʔδʯͱͳΔͨΊɺ ϥΠϒϥϦ΍ݴޠϥϯλΠϜͷ όʔδϣϯࠩҟ͕ੜ·Εʹ͍͘ 12

  13. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͷ͓͞Β͍ ˔%PDLFSίϯςφͱ%PDLFSΠϝʔδ ˔%PDLFSͰղܾͰ͖Δ͜ͱɾղܾͰ͖ͳ͍͜ͱ ˔ίϯςφΦʔέετϨʔγϣϯͷجૅ ˔,VCFSOFUFTͷΞʔΩςΫνϟ֓ཁ ΞδΣϯμ 13

  14. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͰղܾͰ͖Δ͜ͱ ˓શ؀ڥͷڞ௨Խ ˙ϚϧνΫϥ΢υԽʹ͓͚Δύοέʔδϯάච಄ީิ ˙Ϋϥ΢υɾΦϯϓϨ্ͱ։ൃ؀ڥͱͷࠩҟΛzݮΒ͢z ˓ߴ଎ͳΞϓϦέʔγϣϯ഑৴ɾσϓϩΠ ˓$*ͳͲʹΑΔࣗಈԽਪਐ ˙ςετ΋ಉҰ؀ڥͰ࣮ߦՄ %PDLFS͸ۜͷ஄ؙͰ͸ͳ͍

    14
  15. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFS͕ۤखͳ͜ͱ ˓ϞϊϦγοΫͳΞϓϦέʔγϣϯͷ؅ཧ ˙%#ͳͲͷεςʔτͷ؅ཧͱ͔͸ۤख ˠ5IF5XFMWF'BDUPS"QQ ˠ$MPVE/BUJWF5SBJM.BQ %PDLFS͸ۜͷ஄ؙͰ͸ͳ͍ 15

  16. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͰղܾͰ͖ͳ͍͜ͱ ˓ΞϓϦέʔγϣϯͷੈ୅؅ཧ ˓ࣗಈεέʔϦϯά ˓ॊೈͳϦιʔε؅ཧ ˓ϩΪϯάɺ؂ࢹ %PDLFS͸ۜͷ஄ؙͰ͸ͳ͍ 16

  17. ˜;0;05FDIOPMPHJFT *OD %PDLFSΛຊ൪؀ڥͰ ಈ͔͢ʹ͸͍͔ͭ͘ͷ՝୊͕͋Δ 17

  18. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͷ͓͞Β͍ ˔%PDLFSίϯςφͱ%PDLFSΠϝʔδ ˔%PDLFSͰղܾͰ͖Δ͜ͱɾղܾͰ͖ͳ͍͜ͱ ˔ίϯςφΦʔέετϨʔγϣϯͷجૅ ˔,VCFSOFUFTͷΞʔΩςΫνϟ֓ཁ ΞδΣϯμ 18

  19. ˜;0;05FDIOPMPHJFT *OD ˔ຊ൪؀ڥͰ͸ෳ਺ͷίϯςφΛಈ͔͢͜ͱ͕Ұൠత ˓Մ༻ੑ΍଱ো֐ੑΛ্͛ΔͨΊ ˓ࣗಈεέʔϦϯάɺϩʔυόϥϯγϯάɺࣗݾ෮چ౳ʑ ˔֤ίϯςφ͸ಠཱ͓ͯ͠Γɺ͓ޓ͍Λೝࣝ͠ͳ͍ͨΊ ԿΒ͔ͷ؅ཧϨΠϠ͕ඞཁʹͳΔ ˠΦʔέετϨʔγϣϯπʔϧΛೖΕΔ ΦʔέετϨʔγϣϯʁʁ 19

  20. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSίϯςφ͸ΞϓϦέʔγϣϯ։ൃʹ͓͍ͯ ैདྷ՝୊ͱͳ͍͍͔ͬͯͨͭ͘ͷ໰୊Λղফͯ͘͠ΕΔ ˔%PDLFS୯ମͰ͸ຊ൪ӡ༻ʹඞཁͳ؅ཧ༻ͷػೳ͕ෆ଍ ͍ͯ͠ΔͨΊɺಋೖʹ೉͕͋Δ ˔ͦΕΒΛղܾ͢Δʹ͸ɺίϯςφΦʔέετϨʔγϣ ϯ͕ඞཁ ͜͜·Ͱͷ·ͱΊ 20

  21. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSͷ͓͞Β͍ ˔%PDLFSίϯςφͱ%PDLFSΠϝʔδ ˔%PDLFSͰղܾͰ͖Δ͜ͱɾղܾͰ͖ͳ͍͜ͱ ˔ίϯςφΦʔέετϨʔγϣϯͷجૅ ˔,VCFSOFUFTͷΞʔΩςΫνϟ֓ཁ ΞδΣϯμ 21

  22. ˜;0;05FDIOPMPHJFT *OD ˔,VCFSOFUFT͸ίϯςφΦʔέετϨʔγϣϯπʔϧͷ ʮσϑΝΫτελϯμʔυʯ ,VCFSOFUFTʁ 22

  23. ˜;0;05FDIOPMPHJFT *OD 23

  24. ˜;0;05FDIOPMPHJFT *OD ˔ίϯςφ 1PE Λத৺ͱͨ͠෼ࢄγεςϜ ˓ϫʔΫϩʔυ͕ৗʹʮ͋Δ΂͖ঢ়ଶʯΛอͭΑ͏ಈ͘ ,VCFSOFUFTͷ֓ཁ 24 Ref: https://kubernetes.io/docs/tutorials/kubernetes-basics/explore/

  25. ˜;0;05FDIOPMPHJFT *OD :".-ʹΑΔߏ੒؅ཧ 25

  26. ˜;0;05FDIOPMPHJFT *OD ˔ίϯςφͷઃఆ ˓ϕʔεΠϝʔδɺόʔδϣϯɺϙʔτ౳ ˔ཁٻ͢Δ$16΍ϝϞϦͳͲͷϦιʔε ˔ϔϧενΣοΫ ˔؀ڥม਺ ˔ࣗಈεέʔϧͷ਺΍εέʔϧΠϯΞ΢τͷ৚݅ :".-ʹΑΔએݴతͳઃఆ 26

  27. ˜;0;05FDIOPMPHJFT *OD ˔ίϯςφͷઃఆ ˓ϕʔεΠϝʔδɺόʔδϣϯɺϙʔτ౳ ˔ཁٻ͢Δ$16΍ϝϞϦͳͲͷϦιʔε ˔ϔϧενΣοΫ ˔؀ڥม਺ ˔ࣗಈεέʔϧͷ਺΍εέʔϧΠϯΞ΢τͷ৚݅ :".-ʹΑΔએݴతͳઃఆ 27

    
  28. ˜;0;05FDIOPMPHJFT *OD 28

  29. ˜;0;05FDIOPMPHJFT *OD ,VCFSOFUFTͷϦιʔε جຊฤ 29

  30. ˜;0;05FDIOPMPHJFT *OD ˔Ϧιʔεͱ͸ ˓,VCFSOFUFTʹ͓͚Δجຊతͳίϯϙʔωϯτͷ୯Ґ ˔,VCFSOFUFT͕ѻ͏શͯͷந৅֓೦͸Ϧιʔε ˓1PE ˓/PEF ˓$POGJH.BQFUD ,VCFSOFUFTͱϦιʔε 30

  31. ˜;0;05FDIOPMPHJFT *OD ˔,VCFSOFUFTϦιʔε͸:".-Ͱهड़͞ΕɺఆٛͰ͖Δ ˔͜͜Ͱ͸ΞϓϦέʔγϣϯ։ൃऀʹ஌͓͍ͬͯͯ΋Β͍ ͍ͨ΋ͷΛத৺ʹ঺հ͠·͢ Ϧιʔεͱ:".- 31

  32. ˜;0;05FDIOPMPHJFT *OD ˔ίϯςφΛಈ͔ͨ͢Ίͷ࠷খ͔ͭجຊ୯Ґ ˓ίϯςφͷجຊઃఆʢΠϝʔδछผʣ ˓Ϧιʔε੍ݶ ˓ϘϦϡʔϜ ͳͲͷఆٛΛઃఆՄೳ 1PEϦιʔε 32

  33. ˜;0;05FDIOPMPHJFT *OD 33 Image credit: https://cstoku.dev/

  34. ˜;0;05FDIOPMPHJFT *OD ˔1PEΛෳ੡͢ΔϦιʔε ˔͜Εࣗ਎͕ίϯςφΛಈ͔͢ͷͰ͸ͳ͘ɺ1PEΛࢦఆ͠ ͨ਺͚ͩ࡞੒ͯͦ͠ΕΛ؅ཧ͢Δ1PE.BOBHFSͷ໾ׂ 3FQMJDB4FUϦιʔε 34

  35. ˜;0;05FDIOPMPHJFT *OD 35 Image credit: https://cstoku.dev/

  36. ˜;0;05FDIOPMPHJFT *OD ˔࣮ӡ༻ͰίϯςφΛಈ͔͢ͳΒ͜Ε ˔3FQMJDB4FUͷػೳʹՃ͑ɺίϯςφͷΞοϓσʔτઓུ ΍όʔδϣϯཤྺͳͲΛ؅ཧ͢ΔػೳΛ࣋ͭ %FQMPZNFOUϦιʔε 36

  37. ˜;0;05FDIOPMPHJFT *OD 37 % ! )  "'  

    $(&+ *#  Image credit: https://cstoku.dev/
  38. ˜;0;05FDIOPMPHJFT *OD ˔$POGJH.BQ͸,FZ7BMVFͳจࣈྻΛѻ͏Ϧιʔε ˔ྫ͑͹ҎԼͷΑ͏ͳ৘ใΛ1PEʹ஫ೖ͍ͨ͠৔߹ʹ࢖͏ ˓/HJOY΍3BJMTͳͲͷ$POGJHϑΝΠϧ ˙Θ͟Θ͟ϘϦϡʔϜϚ΢ϯτ͢Δ·Ͱ΋ͳ͍΋ͷ ˓؀ڥม਺ $POGJH.BQϦιʔε 38

  39. ˜;0;05FDIOPMPHJFT *OD 39 4FSWJDFɺ*OHSFTTͳͲͷϦιʔε΋ॏཁͰ͕͢ɺ ࠓճ͸ίϯςφͷಈ࡞·ΘΓʹϑΥʔΧε͍ͯ͠ ΔͨΊઆ໌ΛׂѪ͍ͯ͠·͢

  40. ˜;0;05FDIOPMPHJFT *OD :".-ߏ੒؅ཧʹΑΔ੹೚෼ք఺ͷมԽ 40     VM 

      SSH Git push  VM
  41. ˜;0;05FDIOPMPHJFT *OD 41     VM  

     SSH Git push  VM :".-ߏ੒؅ཧʹΑΔ੹೚෼ք఺ͷมԽ
  42. ˜;0;05FDIOPMPHJFT *OD ։ൃεΩʔϚͷมԽͱ %FW0QT 42 ˔։ൃͱΠϯϑϥͷ֞ࠜͷϥΠϯ͕มΘΔ ˓ΞϓϦଆͰߏ੒ͷมߋΛՃ͑ΒΕΔൣғ͕૿͑Δ ˔%FW0QTͷઢҾΛܾΊΔͷ͸ϓϩμΫτ΍αʔϏεʹ ؔΘΔΤϯδχΞࣗ਎

  43. ˜;0;05FDIOPMPHJFT *OD 43 8JOEPXTͷαϙʔτ͸ʁ

  44. ˜;0;05FDIOPMPHJFT *OD 44

  45. ˜;0;05FDIOPMPHJFT *OD 45 ,VCFSOFUFT͔Β 1SPEVDUJPOMFWFMͷ 8JOEPXTαϙʔτ͕։࢝͞Ε·ͨ͠ʂ ࠓͷ࠷৽͸

  46. ˜;0;05FDIOPMPHJFT *OD ˞8JOEPXTίϯςφ͸࢖ͬͨ͜ͱ͕ ͳ͍ͷͰΑ͘Θ͔Γ·ͤΜ 46

  47. ˜;0;05FDIOPMPHJFT *OD ˔%PDLFSίϯςφ͸ΞϓϦέʔγϣϯ։ൃʹ͓͍ͯ ैདྷ՝୊ͱͳ͍͍͔ͬͯͨͭ͘ͷ໰୊Λղফͯ͘͠ΕΔ ˔%PDLFS୯ମͰ͸ຊ൪ӡ༻ʹඞཁͳ؅ཧ༻ͷػೳ͕ෆ଍ ͍ͯ͠ΔͨΊɺίϯςφΦʔέετϨʔγϣϯ͕ඞཁ ˓,VCFSOFUFT͸ͦͷ؀ڥΛఏڙͯ͘͠ΕΔͭͷखஈ ·ͱΊ 47

  48. ˜;0;05FDIOPMPHJFT *OD ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ 48

  49. None