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

telepresence で始める k8s 時代のローカル開発

749095a79bf7731078293abf0585b1f9?s=47 shiro16
March 29, 2019

telepresence で始める k8s 時代のローカル開発

2019.03.29 Cloud Native Meetup Tokyo #7 

749095a79bf7731078293abf0585b1f9?s=128

shiro16

March 29, 2019
Tweet

Transcript

  1. ޙ౻རത(.01FQBCP *OD $MPVE/BUJWF.FFUVQ5PLZP UFMFQSFTFODFͰ࢝ΊΔ LT࣌୅ͷϩʔΧϧ։ൃ

  2. νʔϑςΫχΧϧϦʔυ 5PTIJIJSP(PUP!@TIJSP NJOOFࣄۀ෦!(.0ϖύϘ

  3. None
  4. ຊ೔ͷ͓࿩ͷ಺༰ wUFMFQSFTFODFͱ͸ wUFMFQSFTFODFͷ࢖͍ํ wUFMFQSFTFODFΛಋೖ͢ΔࡍͷϋϚΓϙΠϯτ wUFMFQSFTFODFͷॲཧͷྲྀΕ

  5. ຊ೔࿩͞ͳ͍಺༰ wLVCFSOFUFTDMVTUFSͷ͓࿩ wLVCFSOFUFTͷجຊతͳ͓࿩ wEPDLFSͷ࢖͍ํ w3BJMTʹ͍ͭͯ wTTIʹ͍ͭͯ

  6. UFMFQSFTFODFͱ͸

  7. UFMFQSFTFODFͱ͸ w୯ҰͷαʔϏεΛϦϞʔτͷ,VCFSOFUFTΫϥελʹ઀ଓ͠ͳ͕Βɺ ͦͷαʔϏεΛϩʔΧϧͰ࣮ߦ͢Δ͜ͱ͕ՄೳʹͳΔ wͦͷαʔϏε͕Ϋϥελ಺ͷଞͷαʔϏεʹґଘ͍ͯ͠Δ৔߹Ͱ΋ɺ ୯ҰͷαʔϏεͷਝ଎ͳϩʔΧϧ։ൃΛߦ͏͜ͱ͕ՄೳʹͳΔ wϩʔΧϧͷ։ൃϚγϯΛ,VCFSOFUFTΫϥελͷҰ෦ͷΑ͏ʹಈ࡞͞ ͤΔ͜ͱ͕ՄೳʹͳΔ

  8. LVCFSOFUFTDMVTUFS NBD

  9. LVCFSOFUFTDMVTUFS UFMFQSFTFODF NBD

  10. Ͳ͏͍͏໰୊͕ղܾͰ͖Δ͔ʁ

  11. ղܾͰ͖Δ໰୊ wJNBHFCVJMEQVTIQPEͷJNBHFߋ৽ͷखؒΛল͘͜ͱ͕Մೳ wϦϞʔτͷ,VCFSOFUFTΫϥελʹ઀ଓ͠ͳ͕Β։ൃͰ͖ΔΑ͏ʹͳ ΔͷͰɺϩʔΧϧ͔ΒଞͷαʔϏε ϚΠΫϩαʔϏεతͳଞͷαʔ Ϗε΍%# ʹ઀ଓ͕ՄೳʹͳΔ wLVCFSOFUFTͷαʔϏεͷҰ෦ͱͯ͠ػೳ͢ΔͷͰɺΞΫηεͨ͠ ࡍͷωοτϫʔΫܦ࿏͕΄΅ಉ͡ʹͳΔ

  12. ͭ·Γշదʹ։ൃ͕Ͱ͖Δ

  13. UFMFQSFTFODFͷ࢖͍ํ

  14. લఏ wIUUQ T ͰΞΫηε͕Ͱ͖ΔQPE͕͋Δ wDPOUBJOFS1PSUͰΛ։͚͍ͯΔ w͜Ε͸3BJMTTFSWFSͷσϑΥϧτͷQPSU͕ͦ͏ͳ͚ͩͰมߋͯ͠ ΋໰୊ͳ͍

  15. ·ͣ͸JOTUBMM # homebrew Λ࢖͏ $ brew cask install osxfuse $

    brew install datawire/blackbird/telepresence # ιʔε͔Β $ git clone git@github.com:telepresenceio/telepresence.git $ cd telepresence $ PREFIX=/path/to/install ./install.sh # bin/ ʹͰ͖Δ
  16. UFMFQSFTFODFͷ࢖͍ํͦͷᶃ

  17. ϩʔΧϧͰىಈͨ͠TFSWFSʹ ΞΫηεΛྲྀ͢

  18. ϩʔΧϧTFSWFS΁ # k8s-deployment-name ͸ஔ͖׵͍͑ͨ deployment ͷ໊લ $ telepresence --swap-deployment k8s-deployment-name

    \
 --run bundle exec rails s
  19. UFMFQSFTFODFͷ࢖͍ํͦͷᶄ

  20. ϩʔΧϧͰىಈͨ͠EPDLFS্Ͱ ىಈ͍ͯ͠ΔTFSWFSʹΞΫηεΛྲྀ͢

  21. ϩʔΧϧEPDLFS΁ # k8s-deployment-name ͸ஔ͖׵͍͑ͨ deployment ͷ໊લ $ telepresence --swap-deployment k8s-deployment-name

    \
 --docker-run --rm -it test-image:0.0.1 bundle exec rails s
  22. ͦͷଞͷ࢖͍ํ

  23. ͦͷଞͷ࢖͍ํ wࠓճ঺հͨͭ͠Ҏ֎ʹ΋LVCFSOFUFTDMVTUFSʹ઀ଓͯ͠৭ʑͰ ͖Δ wྫ͑͹UFMFQSFTFODFSVODVSMIUUQNZTFSWJDFͱ΍ΔͱQPE ্ཱ͕͕ͪΓNZTFSWJDFʹΞΫηεͨ݁͠Ռ͕ฦͬͯདྷͨΓ wIUUQTXXXUFMFQSFTFODFJPIPXUPʹશͯ ʁ ॻ͍ͯ͋Δ

  24. ϋϚΓϙΠϯτ

  25. QPSUΛ࢖͍ͬͯΔ৔߹

  26. QPSUΛ࢖͍ͬͯΔ৔߹ wUFMFQSFTFODFΛىಈ͢Δͱର৅ͷQPEͷEFGBVMUͷDPOUBJOFS ͕ஔ͖׵ΘΔ wஔ͖׵ΘͬͨDPOUBJOFSͰطʹQPSUΛ࢖༻͍ͯ͠Δҝ DPOUBJOFS1PSUͰΞΫηεΛड͚͍ͯͯͦΕΛϩʔΧϧʹྲྀͦ͏ ͱࢥͬͯ΋ग़དྷͳ͍

  27. ղܾํ๏ w͓ͦΒ͘ݱঢ়͸ແ͍ͷͰҎ֎Λ࢖͏͔͠ͳ͍

  28. QPEʹෳ਺ίϯςφ

  29. QPEʹෳ਺ίϯςφΛؚΊΔ৔߹ wUFMFQSFTFODFΛىಈ͢Δͱର৅ͷQPEͷEFGBVMUͷDPOUBJOFS ͕ஔ͖׵ΘΔ wͳͷͰEFGBVMUDPOUBJOFSҎ֎ͰDPOUBJOFS1PSUΛ࢖ͬͯͦͷ QPSUͷ௨৴ΛϩʔΧϧʹஔ͖׵͑Δͱ͔΍Ζ͏ͱࢥͬͯ΋ग़དྷͳ͍

  30. ղܾํ๏ wૉ௚ʹEFGBVMUΛ࢖͍·͠ΐ͏ wTXBQEFQMPZNFOULTEFQMPZNFOUOBNFUBSHFUDPOUBJOFSͷ ܗࣜͰࢦఆՄೳ

  31. EPDLFSΛ࢖͏৔߹

  32. EPDLFSΛ࢖͏৔߹ wUFMFQSFTFODFͱ͍͏ΑΓ׬શʹEPDLFSͷ໰୊ wجຊతʹEPDLFSSVOͷPQUJPO͸ͦͷ··࢖͑Δ wͳͷͰWͱ͔ͰNPVOU͍ͨ͠ w͔͠͠EPDLFSͷNPVOU͸஗͍ NPVOU͢ΔTJ[Fʹ΋ΑΔ

  33. ղܾํ๏ wEPDLFSTZODΛ࢖͏ wDBDIFEPQUJPOΛ࢖͏ wEPDLFSͷϝϞϦׂΓ౰ͯΛ૿΍͢

  34. UFMFQSFTFODFͷॲཧͷྲྀΕ

  35. UFMFQSFTFODFͷॲཧͷྲྀΕᶃ wLVCFDUMWFSTJPODPOpHΛۦ࢖ͯ͠ઃఆΛऔಘ͢Δ wLVCFDUMDPOUFYUA্هͰऔಘͨ͠DVSSFOUDPOUFYUPSBSHTͷDPOUFYUAHFU OTEFGBVMUͰLTDMVTUFSͱͷૄ௨֬ೝ w˞ҎԼग़ͯ͘ΔLVCFDUMͷPQUJPOʹ͸શͯADPOUFYUIPHF OBNFTQBDFEFGBVMUA͕ண͕͘௕͍ͷͰলུ wLVCFDUMHFUEFQMPZNFOUPKTPOFYQPSUABSHTͷEFQMPZNFOUAͰ EFQMPZNFOUͷ৘ใΛऔಘ

  36. UFMFQSFTFODFͷॲཧͷྲྀΕᶄ wऔಘͯ͠อ࣋ͨ͠EFQMPZNFOUͷEFGBVMUDPOUBJOFSͷ৘ใΛॻ͖׵͑Δ wPQUJPOͰDPOUBJOFSΛࢦఆͨ͠৔߹͸ࢦఆ͞ΕͨDPOUBJOFS wॻ͖׵͑ͨ಺༰ͰLVCFDUMBQQMZGΛߦ͍ஔ͖׵͑ΔQPEΛ࡞੒ wLVCFDUMTDBMFEFQMPZNFOUATXBQEFQMPZFNFOUͷEFQMPZNFOUA SFQMJDBTͰطଘͷQPEΛ࡟আ wLVCFDUMQPSUGPSXBSEAஔ͖׵͑ͨQPEOBNFA w͜ΕͰQPEͷDPOUBJOFSʹTTIͰ͖ΔΑ͏ʹͳΔ

  37. ͜͜·Ͱ͸ઌͰઆ໌ͨ͠ ύλʔϯͷ࢖͍ํͰڞ௨

  38. ·ͣ͸ϩʔΧϧͰىಈͨ͠ TFSWFSΛ࢖͏৔߹

  39. ϩʔΧϧTFSWFSΛ࢖͏৔߹ᶃ wTTI Ұ෦ུ /QUFMFQSFTFODF!3   wTTI Ұ෦ུ /QUFMFQSFTFODF! -3

    w্هΛߦ͏͜ͱͰQPEͱͷ૒ํ޲ͷΞΫηεΛՄೳʹ͍ͯ͠Δ
  40. ϩʔΧϧTFSWFSΛ࢖͏৔߹ᶄ wߋʹTTIVUUMFUFMFQSFTFODFͱ͍͏πʔϧ TTIVUUMFΛ UFMFQSFTFODF༻ʹΧελϚΠζͨ͠΋ͷ Λ࢖ͬͯLVCFSOFUFT্ ͷଞͷαʔϏε΁ͷΞΫηεΛՄೳʹ͍ͯ͠Δ

  41. ࣍ʹϩʔΧϧͰىಈͨ͠ EPDLFSΛ࢖͏৔߹

  42. ϩʔΧϧEPDLFSΛ࢖͏৔߹ᶃ wTTI Ұ෦ུ /QUFMFQSFTFODF! -3 wEPDLFSSVOͰEBUBXJSFUFMFQSFTFODFMPDBMΛ࢖ͬͯEPDLFS DPOUBJOFSΛ্ཱͪ͛Δ w͜ͷDPOUBJOFS͸QSPYZ༻Ͱ͜ͷޙʹىಈ͢ΔDPOUBJOFSͱQPE Λͭͳ͙໾ׂΛ͍ͯ͠ΔΑ͏Ͱ͢ɻ

  43. ϩʔΧϧEPDLFSΛ࢖͏৔߹ᶄ wTTI Ұ෦ུ /QSPPU!3  wTTI Ұ෦ུ /QUFMFQSFTFODF!3  

    wEPDLFSSVOҎ߱ͷΦϓγϣϯΛࢦఆͯ͠࠷ऴతʹΞΫηεΛྲྀ͢ EPDLFSDPOUBJOFSΛىಈ͢Δ
  44. ࠷ޙʹ

  45. ͱΓ͋͑ͣͲΜͳײ͔͡ࢼ͍ͨ͠ਓ޲͚

  46. ͱΓ͋͑ͣࢼ͍ͨ͠ wIUUQTHJUIVCDPNUFMFQSFTFODFJPUFMFQSFTFODFUSFF NBTUFSFYBNQMFTHVFTUCPPL w্هʹ(,&༻ͷॾʑ͕͋ΔͷͰࢼͤͦ͏ ˞ࣗ෼͸(,&࢖ͬͯͳ ͍ͷͰࢼͯ͠ͳ͍  wIUUQTHJUIVCDPNTIJSPUFMFQSFTFODFFYBNQMFT wͪ͜ΒͰ΋͓खܰʹ͓ࢼ͍͚ͨͩ͠·͢ɻ

  47. Ҏ্UFMFQSFTFODFͷ঺հͰͨ͠

  48. ͋Γ͕ͱ͏͍͟͝·ͨ͠