クラウドネイティブな開発環境への移行/Move to the cloud native development environment

22522e2bc35255ab75308c399ff782f6?s=47 Takuma Kume
December 04, 2019

クラウドネイティブな開発環境への移行/Move to the cloud native development environment

KIXS #10

22522e2bc35255ab75308c399ff782f6?s=128

Takuma Kume

December 04, 2019
Tweet

Transcript

  1. ,*94 ։ൃ؀ڥͷมભͱ Ϋϥ΢υωΠςΟϒ΁ͷҠߦ

  2. (.0ϖύϘגࣜձࣾ ٱถ୓അ!UBLVNBLVNF ιϑτ΢ΣΞΤϯδχΞ

  3. None
  4. αʔϏε։͔࢝Β໿೥ վળ͠์୊Ͱ͢ʂ

  5. ϩϦϙοϓʂͷݱࡏͷߏ੒ͱϑΣʔζ w ϩϦϙοϓʂͷ8FCαΠτ΍ίϯτϩʔϧύωϧͳͲͷ8FCΞϓϦ έʔγϣϯ͸ɺ0QFOTUBDLͰߏங͞ΕͨϓϥΠϕʔτΫϥ΢υ্ʹ 7.ͱͯ͠ߏ੒͞Ε͍ͯΔɻ w ݱࡏ͸ɺΫϥ΢υωΠςΟϒͳ؀ڥΛ໨ࢦͯ͠ɺ·ͣ͸։ൃ؀ڥ͔Β LVCFSOFUFT΍पลٕज़ͷಋೖΛߦ͍ͬͯΔɻ w ࠓޙɺϓϩμΫγϣϯ؀ڥ΋Ϋϥ΢υωΠςΟϒͳٕज़Λಋೖ͍ͯ͠

    ͘༧ఆͱͳ͍ͬͯΔɻ  
  6. ຊ೔ͷ͓࿩ wϩϦϙοϓͷ։ൃ؀ڥͷมભͱͦΕͧΕͷ՝୊ wϩϦϙοϓͰߏஙͨ͠Ϋϥ΢υωΠςΟϒͳ ։ൃ؀ڥΛݱঢ়ͷ՝୊Λަ͑ͯ঺հ Ϋϥ΢υωΠςΟϒͳ։ൃ؀ڥΛࢧ͑Δཁૉٕज़ͷৄ͍͠આ໌͸࣌ؒͷ౎߹্ɺҰ෦ׂѪ͍ͯ͠·͢ɻ ϦϑΝϨϯεΛ͚͍ͭͯΔͷͰޙ΄Ͳޚཡ͍ͩ͘͞ʂ

  7. ͱ͜ΖͰɺ օ͞Μ͕ීஈ࢖͏։ൃ؀ڥ͸ Ϋϥ΢υωΠςΟϒͰ͔͢ʁ

  8. ग़యIUUQTTQFBLFSEFDLDPNKBDPQFOGFJCJJQNPVDMPVEOBUJWFGBMTFTIJKJF

  9. ग़యIUUQTTQFBLFSEFDLDPNKBDPQFOGFJCJJQNPVDMPVEOBUJWFGBMTFTIJKJF

  10. ։ൃ؀ڥ͸͜͜਺೥Ͱ ࣌୅ͷมભͱͱ΋ʹ ଟ͘ͷมԽ͕͋Γ·ͨ͠

  11. ෺ཧαʔό ,7. BQQ BQQ ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# 1$

    " σϓϩΠ BQQΛ։ൃʹ࢖͍·͢ʙ ڞ༻7.ظ
  12. ෺ཧαʔό ,7. BQQ BQQ ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# 1$

    " σϓϩΠ BQQΛ։ൃʹ࢖͍·͢ʙ ڞ༻7.ظ 1$ # !"͞Μ BQQΛগ͠࢖͍͍ͨͰ͢ʂ
  13. ෺ཧαʔό ,7. BQQ BQQ ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# 1$

    " WJIUUQEDPOG ڞ༻7.ظ ͳΜ͔ಈ͔Μ IUUQEDPOGΠδΔ͔
  14. ෺ཧαʔό ,7. BQQ BQQ ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ ࣾ಺-"/ "1* %#

    " σϓϩΠ ڞ༻7.ظ 1$ # BQQΛ։ൃʹ࢖͍·͢ʙ !IFSF BQQͷαʔό͕ ಈ͔ͳ͍ΜͰ͚͢Ͳʂ ͏ͬԶͩ
  15. ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# ϩʔΧϧ7.ظ 1$ 7JSUVBM#PY BQQ BQQ

    WBHSBOU ϓϩμΫγϣϯ؀ڥΛDIFG౳Ͱ ίʔυԽͨ͜͠ͱͰɺखݩͷ WBHSBOUVQ࣌ʹDIFGͰ ϓϩϏδϣχϯά͢Δߏ੒ʹ ڞ༻ͷ%#΍Ҡߦ͍ͯ͠ͳ͍Ұ෦ϩʔϧ͸ -"/಺Ͱ௨৴͢Δ ։ൃ͕׆ൃͳϩʔϧ͔ΒҠߦ͍ͯͬͨ͠
  16. ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# ϩʔΧϧ7.ظ 1$ 7JSUVBM#PY BQQ BQQ

    WBHSBOU ͏ͬىಈ͠ͳ͘ͳͬͨ DIFG͕͏·͘ಈ͍ͯͳ͍ ։ൃ؀ڥΩϨΠʹ͍ͨ͠ͷͰҰ౓࡞Γ௚͢ʙ ͏ͬϓϩϏδϣχϯά݁ߏ͔͔࣌ؒΔͳ ͳΜ͔͠ΒΜ͚Ͳಈ͔Μ͘ͳͬͨΜͰ͢
  17. ϖύϘͰ͸ɺ ΤϯδχΞ͚ͩͰͳ͘ σβΠφʔ΋ಉ͡։ൃ؀ڥΛ ࢖͍ͬͯ·͢ɻ

  18. ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# ϩʔΧϧίϯςφظ 1$ %PDLFS BQQ BQQ

    EPDLFSDPNQPTF ΞϓϦΛίϯςφԽͯ͠ खݩͷιʔείʔυΛϚ΢ϯτͯ͠ ։ൃͰ͖ΔΑ͏ʹͳͬͨ
  19. ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# ϩʔΧϧίϯςφظ 1$ %PDLFS BQQ BQQ

    EPDLFSDPNQPTF ͳΜ͔͠ΒΜ͚Ͳಈ͔Μ͘ͳͬͨΜͰ͢ ɾखݩͷΠϝʔδ͕ݹ͍ ɾผͷίϯςφͱϙʔτ͕ඃͬͯಈ͍ͯͳ͍ ɹίϯςφ͕͋Δ ɾ͍Ζ͍ΖͳαʔϏεͷ։ൃ؀ڥ͕खݩʹཚཱͯ͠ ɹύϑΥʔϚϯε͕ 
  20. ໰୊͕ൃੜ͢Δ౓ʹɺ ΤϯδχΞ͕ग़ಈ͢Δඞཁ͕͋Δ͠ɺ ґཔ͢Δଆ΋ਏ͍

  21. ؀ڥґଘ໰୊ͷղܾͷ৔߹͸ ͦͷਓͷ1$ΛआΓͯ ΞϨίϨ͢Δඞཁ΋͋ͬͯ ੜ࢈ੑ͕௿͍

  22. Ϋϥ΢υωΠςΟϒͳ։ൃ؀ڥʹͯ͠ ͜ͷ՝୊Λղܾ͢Δʂ

  23. ։ൃ؀ڥʹٻΊͨ͜ͱ w޷͖ͳ࣌ʹ͙͢࢖͑Δ wյΕͯ΋؆୯ʹ΋ͱʹ໭Δ w؀ڥґଘʹΑΔ໰୊͕ൃੜ͠ʹ͍͘ wৗʹ࠷৽ͷ؀ڥΛ࢖͑Δ

  24. BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT σʔληϯλʔ

    ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# ·ͩҠߦͰ͖ͯͳ͍ ϩʔϧ 1$ " 1$ # ݱࡏͷ։ൃ؀ڥ
  25. BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT σʔληϯλʔ

    ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# 1$ " 1$ # ݱࡏͷ։ൃ؀ڥ BQQ BQQ BQQ BQQ 6TFS" 6TFS# 1$ " 1$ # ݸผͷ։ൃ؀ڥΛ༻ҙͯ͠ ޷͖ͳ࣌ʹ࢖͑Δ
  26. BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT σʔληϯλʔ

    ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# 1$ " 1$ # ݱࡏͷ։ൃ؀ڥ ,VCFSOFUFT LVCFSOFUFTΛ࠾༻͍ͯ͠ΔͷͰ ໰୊͕ൃੜͯ͠΋ݩʹ໭͠΍͍͢
  27. BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT σʔληϯλʔ

    ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# 1$ " 1$ # ݱࡏͷ։ൃ؀ڥ Ϋϥ΢υ্ʹ։ൃ؀ڥ͕͋ΔͨΊ खݩͷ؀ڥґଘͷ໰୊͕ ൃੜ͠ʹ͍͘ BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT σʔληϯλʔ
  28. ։ൃ؀ڥʹٻΊͨ͜ͱ w޷͖ͳ࣌ʹ͙͢࢖͑Δ wյΕͯ΋؆୯ʹ΋ͱʹ໭Δ w؀ڥґଘʹΑΔ໰୊͕ൃੜ͠ʹ͍͘ wৗʹ࠷৽ͷ؀ڥΛ࢖͑Δ

  29. ৗʹ࠷৽ͷ؀ڥΛ࢖͑Δ ΞϓϦͷมߋΛ NBTUFSϒϥϯνʹ 1VTI ΞϓϦͷϦϙδτϦ ։ൃऀ "SHP$% NBTUFSϒϥϯνͷ มߋΛ؂ࢹ ΞϓϦͷίϯςφ

    ΠϝʔδΛ #VJME1VTI 1VTI )PPL 1PMM 1VTI NBOJGFTUTͷ JNBHFUBHΛ ࠷৽ʹVQEBUF LVCFSOFUFTͷNBOJGFTUT ͷϦϙδτϦ QSJWBUF EPDLFSSFHJTUSZ 1VTI NBOJGFTUTΛ LVCFSOFUFT؀ڥʹ LVCFDUMͰBQQMZ "QQMZ ։ൃ؀ڥͷ LVCFSOFUFTDMVTUFS (JU0QTΛ࣮ݱ͢Δ $%πʔϧ
  30. ৗʹ࠷৽ͷ؀ڥΛ࢖͑Δ ΞϓϦͷมߋΛ NBTUFSϒϥϯνʹ 1VTI ΞϓϦͷϦϙδτϦ ։ൃऀ "SHP$% NBTUFSϒϥϯνͷ มߋΛ؂ࢹ ΞϓϦͷίϯςφ

    ΠϝʔδΛ #VJME1VTI 1VTI )PPL 1PMM 1VTI NBOJGFTUTͷ JNBHFUBHΛ ࠷৽ʹVQEBUF LVCFSOFUFTͷNBOJGFTUT ͷϦϙδτϦ QSJWBUF EPDLFSSFHJTUSZ 1VTI NBOJGFTUTΛ LVCFSOFUFT؀ڥʹ LVCFDUMͰBQQMZ "QQMZ ։ൃ؀ڥͷ LVCFSOFUFTDMVTUFS (JU0QTΛ࣮ݱ͢Δ $%πʔϧ ΞϓϦͷίϯςφ ΠϝʔδΛ #VJME1VTI NBOJGFTUTͷ JNBHFUBHΛ ࠷৽ʹVQEBUF NBOJGFTUTΛ LVCFSOFUFT؀ڥʹ LVCFDUMͰBQQMZ 5BTL 5BTL 5BTL 1JQFMJOF https://speakerdeck.com/pyama86/cloudnative-buildpacksdechuang-ru-cloudnativenakai-fa-ti-yan?slide=45
  31. ։ൃ؀ڥʹٻΊͨ͜ͱ w޷͖ͳ࣌ʹ͙͢࢖͑Δ wյΕͯ΋؆୯ʹ΋ͱʹ໭Δ w؀ڥґଘʹΑΔ໰୊͕ൃੜ͠ʹ͍͘ wৗʹ࠷৽ͷ؀ڥΛ࢖͑Δ

  32. ΞϓϦͷมߋΛ NBTUFSϒϥϯνʹ 1VTI ΞϓϦͷϦϙδτϦ ։ൃऀ "SHP$% NBTUFSϒϥϯνͷ มߋΛ؂ࢹ ΞϓϦͷίϯςφ ΠϝʔδΛ

    #VJME1VTI 1VTI )PPL 1PMM 1VTI NBOJGFTUTͷ JNBHFUBHΛ ࠷৽ʹVQEBUF LVCFSOFUFTͷNBOJGFTUT ͷϦϙδτϦ QSJWBUF EPDLFSSFHJTUSZ 1VTI NBOJGFTUTΛ LVCFSOFUFT؀ڥʹ LVCFDUMͰBQQMZ "QQMZ ։ൃ؀ڥͷ LVCFSOFUFTDMVTUFS (JU0QTΛ࣮ݱ͢Δ $%πʔϧ NBOJGFTUTΛ LVCFSOFUFT؀ڥʹ LVCFDUMͰBQQMZ "QQMZ ։ൃ؀ڥͷ LVCFSOFUFTDMVTUFS શ։ൃऀͷ؀ڥΛͲͷΑ͏ʹੜ੒͍ͯ͠Δ͔ʁ
  33. LVTUPNJ[F apiVersion: apps/v1beta1 kind: Deployment metadata: name: app spec: replicas:

    1 template: metadata: labels: app: app spec: containers: - name: app image: nginx:latest ports: - containerPort: 8080 deployment.yaml apiVersion: v1 kind: Service metadata: name: app spec: type: ClusterIP selector: app: app ports: - port: 8080 protocol: TCP targetPort: 8080 service.yaml resources: - deployment.yaml - service.yaml namePrefix: dev commonLabels: env: dev patchesJson6902: - target: version: v1 kind: Service name: app path: replace_selector.yaml kustomization.yaml - op: replace path: /spec/selector value: app: app env: dev > kubectl kustomize .
  34. LVTUPNJ[F --- apiVersion: v1 kind: Service metadata: labels: env: dev

    name: devapp spec: ports: - port: 8080 protocol: TCP targetPort: 8080 selector: app: app env: dev type: ClusterIP apiVersion: apps/v1beta1 kind: Deployment metadata: labels: env: dev name: devapp spec: replicas: 1 selector: matchLabels: env: dev template: metadata: labels: app: app env: dev spec: containers: - image: nginx:latest name: app ports: - containerPort: 8080 namePrefix: dev commonLabels: env: dev - op: replace path: /spec/selector value: app: app env: dev LVTUPNJ[BUJPOZBNMʹج͍ͮͯϦιʔεΛมߋ͢Δ
  35. ։ൃऀશһͷ؀ڥΛLVTUPNJ[FΛ׆༻ͯ͠ੜ੒ resources: - deployment.yaml - service.yaml namePrefix: dev commonLabels: env:

    dev patchesJson6902: - target: version: v1 kind: Service name: app path: replace_selector.yaml kustomization.yaml - op: replace path: /spec/selector value: app: app env: dev ɾϦετΛݩʹ࠶ؼతʹੜ੒͢Δػೳ͸ͳ͍ ɾ੺Ͱࣔ͢෦෼Λ։ൃऀຖʹॻ͖׵͑ͯ ɹ࠶ؼతʹLVCFSOFUFT؀ڥʹBQQMZͯ͠ɺ ɹ։ൃऀຖͷ؀ڥΛੜ੒͍ͯ͠Δ ɾॻ͖׵͑ʹ͸ZRίϚϯυΛ࢖͍ͬͯΔ ͨͩ ɾZRίϚϯυͰZBNMΛॻ͖׵͑Δಛੑ্ ɹ؅ཧ͕൥ࡶʹͳΓɺมߋʹऑ͍ ɾLVCFDUMඪ४Ͱఏڙ͞Ε͍ͯΔ ɹLVTUPNJ[FͷػೳΛ௒͑ͯΧελϚΠζ ɹ͍ͯ͠ΔͨΊɺ࠷ྑͷํ๏Λ໛ࡧத
  36. BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT 1$

    " 1$ # LVCFSOFUFT্ͷΞϓϦέʔγϣϯʹରͯ͠ ͲͷΑ͏ͳํ๏Ͱ։ൃ͍ͯ͠Δͷ͔ʁ
  37. UFMFQSFTFODFATXBQEFQMPZNFOUAػೳ https://speakerdeck.com/shiro16/telepresence-deshi-meru-k8s-shi-dai-falserokarukai-fa?slide=9

  38. deployment pod replica: 1 UFMFQSFTFODFͷ՝୊ᶃ app1-deployment pod replica: 1 app1-service

    app1-deployment replica: 0 app1-service ΫϥΠΞϯτ container ઀ଓલ ઀ଓޙ UFMFQSFTFODFa TXBQEFQMPZNFOUBQQEFQMPZNFOU طଘͷEFQMPZNFOUͷ SFQMJDBΛʹ͢Δ UFMFQSFTFODFͷதܧ༻ͷ EFQMPZNFOUʹࠩ͠ସ͑Δ ։ൃର৅
  39. UFMFQSFTFODFͷ՝୊ᶃ deployment pod replica: 1 app1-deployment replica: 0 app1-service container

    UFMFQSFTFODFa TXBQEFQMPZNFOUBQQEFQMPZNFOU ɾΫϥΠΞϯτͰಈ࡞͢ΔUFMFQSFTFODF ɹϓϩηεʹରͯ͠$UM$Ͱ4*(*/5Λ ɹૹΔͱɺݩͷEFQMPZNFOUͷSFQMJDB਺Λ ɹ໭ͯ͠ɺUFMFQSFTFODF͕ىಈͨ͠ ɹEFQMPZNFOUΛ࡟আͯ͘͠ΕΔɻ ɾ͔͠͠ɺྫ͑͹UFMFQSFTFODF͕ىಈ ɹ͍ͯ͠ΔλʔϛφϧΛམͱͯ͠γΣϧ ɹ͝ͱࡴ͢ͱɺ্هͷΫϦʔϯφοϓॲཧ ɹ͕ൃੜ͠ͳ͍ɻ FSSPS
  40. UFMFQSFTFODFͷ՝୊ᶄ deployment pod replica: 1 app1-deployment replica: 1 app1-service container

    UFMFQSFTFODFa TXBQEFQMPZNFOUBQQEFQMPZNFOU pod ΞϓϦέʔγϣϯͷNBTUFSʹมߋ͕͋ͬͨ৔߹ʹ ৗʹ࠷৽ͷ؀ڥʹ͢Δػߏ͕ಇ͖ॏෳىಈঢ়ଶ ʹͳΔ
  41. UFMFQSFTFODFͷ՝୊ᶅ deployment pod replica: 1 app1-deployment replica: 0 app1-service container

    ͜͜Ͱ࢖ΘΕ͍ͯͨ ΠϝʔδΛ खݩͰىಈ͢Δ ΞϓϦͷNBTUFS͕ߋ৽͞ΕΔ౓ʹΠϝʔδ͕ߋ৽͞ΕΔɻ ˠϦϦʔε͕ଟ͍΄ͲJNBHFQVMMͷස౓্͕͕ΔͷͰΠϝʔδαΠζʹΑͬͯ͸ɺ ɹ͜ͷ͕࣌ؒϘτϧωοΫͱͳΔɻ
  42. ·ͱΊ w։ൃ؀ڥ͸࣌୅ͷมԽͱͱ΋ʹɺ՝୊Λղ ܾ͢ΔͨΊʹมԽͨ͠ɻ wಉ༷ʹ՝୊Λղܾ͢ΔͨΊʹLVCFSOFUFTΛ ࢝Ίͱͨ͠Ϋϥ΢υωΠςΟϒΛ࣮ݱ͢Δͨ Ίʹదͨ͠पลπʔϧΛ૊Έ߹Θͤͯཧ૝ͷ ։ൃ؀ڥͷߏஙΛਐΊ͍ͯΔɻ

  43. ͜Ε͔ΒϓϩμΫγϣϯΛؚΊͯ Ϋϥ΢υωΠςΟϒ΍͍͖͍ͬͯͨਓืूʂ ࠷৽ͷ࠾༻৘ใΛνΣοΫˠ !QC@SFDSVJU