Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

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

Takuma Kume
December 04, 2019

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

KIXS #10

Takuma Kume

December 04, 2019
Tweet

More Decks by Takuma Kume

Other Decks in Technology

Transcript

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

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

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

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

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

    WBHSBOU ͏ͬىಈ͠ͳ͘ͳͬͨ DIFG͕͏·͘ಈ͍ͯͳ͍ ։ൃ؀ڥΩϨΠʹ͍ͨ͠ͷͰҰ౓࡞Γ௚͢ʙ ͏ͬϓϩϏδϣχϯά݁ߏ͔͔࣌ؒΔͳ ͳΜ͔͠ΒΜ͚Ͳಈ͔Μ͘ͳͬͨΜͰ͢
  6. ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# ϩʔΧϧίϯςφظ 1$ %PDLFS BQQ BQQ

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

    EPDLFSDPNQPTF ͳΜ͔͠ΒΜ͚Ͳಈ͔Μ͘ͳͬͨΜͰ͢ ɾखݩͷΠϝʔδ͕ݹ͍ ɾผͷίϯςφͱϙʔτ͕ඃͬͯಈ͍ͯͳ͍ ɹίϯςφ͕͋Δ ɾ͍Ζ͍ΖͳαʔϏεͷ։ൃ؀ڥ͕खݩʹཚཱͯ͠ ɹύϑΥʔϚϯε͕ 
  8. BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT σʔληϯλʔ

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

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

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

    ෺ཧαʔό ,7. ձࣾͷย۱ͷαʔόʔࣨ "1* %# 1$ " 1$ # ݱࡏͷ։ൃ؀ڥ Ϋϥ΢υ্ʹ։ൃ؀ڥ͕͋ΔͨΊ खݩͷ؀ڥґଘͷ໰୊͕ ൃੜ͠ʹ͍͘ BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT σʔληϯλʔ
  12. ৗʹ࠷৽ͷ؀ڥΛ࢖͑Δ ΞϓϦͷมߋΛ NBTUFSϒϥϯνʹ 1VTI ΞϓϦͷϦϙδτϦ ։ൃऀ "SHP$% NBTUFSϒϥϯνͷ มߋΛ؂ࢹ ΞϓϦͷίϯςφ

    ΠϝʔδΛ #VJME1VTI 1VTI )PPL 1PMM 1VTI NBOJGFTUTͷ JNBHFUBHΛ ࠷৽ʹVQEBUF LVCFSOFUFTͷNBOJGFTUT ͷϦϙδτϦ QSJWBUF EPDLFSSFHJTUSZ 1VTI NBOJGFTUTΛ LVCFSOFUFT؀ڥʹ LVCFDUMͰBQQMZ "QQMZ ։ൃ؀ڥͷ LVCFSOFUFTDMVTUFS (JU0QTΛ࣮ݱ͢Δ $%πʔϧ
  13. ৗʹ࠷৽ͷ؀ڥΛ࢖͑Δ ΞϓϦͷมߋΛ 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
  14. ΞϓϦͷมߋΛ 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 શ։ൃऀͷ؀ڥΛͲͷΑ͏ʹੜ੒͍ͯ͠Δ͔ʁ
  15. 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 .
  16. 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ʹج͍ͮͯϦιʔεΛมߋ͢Δ
  17. ։ൃऀશһͷ؀ڥΛ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ͷػೳΛ௒͑ͯΧελϚΠζ ɹ͍ͯ͠ΔͨΊɺ࠷ྑͷํ๏Λ໛ࡧத
  18. BQQ BQQ BQQ BQQ 6TFS" 6TFS# ϓϥΠϕʔτΫϥ΢υ 0QFOTUBDL ,VCFSOFUFT 1$

    " 1$ # LVCFSOFUFT্ͷΞϓϦέʔγϣϯʹରͯ͠ ͲͷΑ͏ͳํ๏Ͱ։ൃ͍ͯ͠Δͷ͔ʁ
  19. 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ʹࠩ͠ସ͑Δ ։ൃର৅
  20. UFMFQSFTFODFͷ՝୊ᶃ deployment pod replica: 1 app1-deployment replica: 0 app1-service container

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

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

    ͜͜Ͱ࢖ΘΕ͍ͯͨ ΠϝʔδΛ खݩͰىಈ͢Δ ΞϓϦͷNBTUFS͕ߋ৽͞ΕΔ౓ʹΠϝʔδ͕ߋ৽͞ΕΔɻ ˠϦϦʔε͕ଟ͍΄ͲJNBHFQVMMͷස౓্͕͕ΔͷͰΠϝʔδαΠζʹΑͬͯ͸ɺ ɹ͜ͷ͕࣌ؒϘτϧωοΫͱͳΔɻ