$30 off During Our Annual Pro Sale. View Details »

managed_Kubernetes_on-premises.pdf

yuhara
December 05, 2018

 managed_Kubernetes_on-premises.pdf

yuhara

December 05, 2018
Tweet

More Decks by yuhara

Other Decks in Technology

Transcript

  1. ΦϯϓϨͩͬͯ͜͜·ͰͰ͖Δ KubernetesͰ࡞ΔࣗલPaaS Takaaki Yuhara Infrastructure Service Group Gurunavi, Inc. 2018.12.04

    Japan Container Days v18.12
  2. Takaaki Yuhara Infrastructure Engineer 2014~ ͙Δͳͼ ɹ͙ΔͳͼશͯͷαΠτΠϯϑϥͷߏஙͱӡ༻ ɹVirtualization/OS/Middleware/Container/k8s…ϨΠϠʔΛ୲౰ ɹΠϯϑϥͷίʔυԽɾࣗಈԽɺ؂ࢹ΍ςετͷ࠷దԽ etc…

  3. ΦϯϓϨKubernetes kubeadm, Rancher, RKEͳͲɺखܰʹΦϯϓ ϨϛεͰ΋ߏஙͰ͖ΔΑ͏ʹͳΓ·ͨ͠ɻ ςʔϚɿΦϯϓϨKubernetesΛͲͷΑ͏ʹ׆༻͢Δ͔

  4. Kubernetesに詳しくなくても誰でも簡単に使えるプラットフォーム

  5. γεςϜ֓ཁ Generator API Management Console Load Barancer Ingress Service Deployment

    Namespace
  6. γεςϜ֓ཁ Generator API Management Console Load Barancer ར༻ऀ͸Management Console͔ Βඞཁࣄ߲Λೖྗ͠ར༻։࢝Ϙλϯ

    ΛΫϦοΫ
  7. γεςϜ֓ཁ Generator API Management Console Load Barancer Generator APIͷ֤छδϣϒʹϦΫ Τετ͕౉Δ

  8. γεςϜ֓ཁ Generator API Management Console Load Barancer Ingress Service Deployment

    Namespace Kubernetes APIΛ௨ͯ͡ Namespace΍ඞཁͱͳΔϦιʔ ε܈Λ࡞੒
  9. γεςϜ֓ཁ Generator API Management Console Load Barancer Ingress Service Deployment

    Namespace GitLab APIΛ௨ͯ͡ϓϩδΣΫτ ͷ࡞੒ʢςϯϓϨʔτ͔ΒͷΠϯ ϙʔτʣͱCI/CD༻ͷVariablesͷ ઃఆ Container Registry΋ར༻Մ
  10. γεςϜ֓ཁ Generator API Management Console Load Barancer Ingress Service Deployment

    Namespace LoadBalancerʢk8sͷ֎ʣͷઃఆ Λมߋ͠ΫϥΠΞϯτ͔ΒͷΤϯυ ϙΠϯτΛఏڙ
  11. •  Kubernetes ্ͷNamespace΍֤छϦιʔε܈ •  ΞϓϦέʔγϣϯʹର͢ΔΤϯυϙΠϯτ •  GitLab ͷ Projectʢ֤छઃఆ͕ࢪ͞Εͨঢ়ଶʣ Management

    Console ͔Β࡞੒ ޙ͸ΞϓϦΛ࡞੒ͯ͠Commit & Push͢Δ͚ͩ
  12. Kubernetes Resouce Generator •  KubernetesͷϦιʔε܈Λ࡞ΔͨΊʹಠࣗʹ࡞੒ͨ͠API •  YAMLϚχϡϑΣετΛapply͍ͯ͠ΔΑ͏ͳΠϝʔδ •  Kubernetes client

    pythonΛ࢖༻ •  Officialʹఏڙ͞Ε͍ͯΔgo΍pythonͷClient Library ɹɹhttps://github.com/kubernetes-client/python ɹɹhttps://github.com/kubernetes/client-go •  Python FlaskͰREST APIԽ
  13. Kubernetes Client Python ྫʣNamespaceͷ࡞੒

  14. DeployͷྲྀΕ

  15. γεςϜ֓ཁ Developer Load Barancer Ingress Service Deployment Namespace Container Registry

    ίʔυΛGitLabͷϓϩδΣΫ τʹରͯ͠Commit / Push
  16. γεςϜ֓ཁ Developer Load Barancer Ingress Service Deployment Namespace Container Registry

    GitLab CI͕։࢝͞Εk8s্ͷrunner ʹରͯ͠Pipelineͷ࣮ߦΛ໋ྩ
  17. γεςϜ֓ཁ Developer Load Barancer Ingress Service Deployment Namespace workspace Container

    Registry #01 Build Stage Kubernetes্ͰίϯςφϏϧυ ༻ͷίϯςφΛ࣮ߦ
  18. γεςϜ֓ཁ Developer Load Barancer Ingress Service Deployment Namespace workspace Container

    Registry #01 Build Stage GitLabͷProjectΛclone͠ DockerfileΛݩʹΠϝʔδϏϧυ
  19. γεςϜ֓ཁ Developer Load Barancer Ingress Service Deployment Namespace workspace Container

    Registry #01 Build Stage ϏϧυΠϝʔδΛGitLab Container RegistryʹPush
  20. γεςϜ֓ཁ Developer Load Barancer Ingress Service Deployment Namespace workspace Container

    Registry #02 Deploy Stage Runner͔ΒDeploy༻ͷίϯςφ Λىಈɻ Kubernetes APIΛ௨ͯ͡ Deploymentʹରͯ͠Rolling updateΛ໋ྩ
  21. γεςϜ֓ཁ Developer Load Barancer Ingress Service Deployment Namespace Container Registry

    ϏϧυΠϝʔδ͔ΒRolling updateΛ࣮ߦ
  22. GitLab & GitLab CI •  GitLabɺGitLab Container RegistryΛར༻ •  CI/CDδϣϒ͸Kubernetes

    executorͰ࣮ߦ •  .gitlab-ci.ymlͰύΠϓϥΠϯΛఆٛ͠ɺ࣮ߦ͍ͨ͠ॲཧͱɺͦͷॲཧΛ ࣮ߦ͢ΔϕʔεΠϝʔδΛબ୒ʢServerlessͳײ֮ʣ •  εςʔδຖʹtagΛࢦఆ͢Δ͜ͱͰɺDevelop/Staging/Productionͱ ͍ͬͨܗͰ࣮ߦ؀ڥΛ෼͚ΒΕΔ Build to develop stage: build only: - /^develop.*/ image: gcr.io/kaniko-project/executor:debug script: - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination …(লུ) tags: - develop .gitlab-ci.ymlͷҰ෦Λൈਮ
  23. Kubernetes ExecutorΛ࢖ͬͨPipeline •  #01 Build Stage •  Builderͱͯ͠͸dind(docker in docker)

    ͔ kanikoͷબ୒͕Մ •  kaniko͸Google͕։ൃ͢ΔϏϧμʔɻKubernetes্ͰΠϝʔδ Ϗϧυ͢Δ͜ͱΛ૝ఆ͠privilegedແ͠ͰϏϧυՄ ɹɹhttps://github.com/GoogleContainerTools/kaniko •  #02 Deploy Stage •  Kubernetes client pythonͰ࡞੒ͨ͠ಠࣗπʔϧΛ࢖༻ •  Rolling update ΍ ຊ൪ͰͷB/G DeploymentɺRollback౳ʹର Ԡ
  24. FeatureϒϥϯνରԠ •  FeatureϒϥϯνΛ࡞੒͢Δ ͱͦΕʹରԠͨ͠Endpointͱ Service/DeploymentΛࣗಈ తʹߏ੒ •  GitLab CIͱ࿈ಈ͠ϒϥϯν໊ ʹԠͨ͡Development͕ߋ

    ৽͞ΕΔ Ingress Service Deployment Service Deployment Service Deployment a.com b.com c.com develop branch feature/a branch feature/b branch
  25. ։ൃϑϩʔ develop staging release master feature/a ֤ϒϥϯνͰͷCommit΍Merge୯ҐͰCI/CDΛ࣮ߦ ӡ༻͸Gitૢ࡞Ͱ׬݁ ϓϧϦΫΤετɺϨϏϡʔɺϚʔδ ͷϓϩηεΛճ͢ࣄʹूத

    tag v1.1.0
  26. •  Push Code, Not Container •  ӡ༻͸ϓϧϦΫΤετͰ࣮ߦ͞ΕΔ Weaveworks : Alexis

    Richardsonࢯ •  kubectl౳ͷίϚϯυϥΠϯπʔϧ͸࢖Θͳ͍ʢGitૢ࡞ͷΈʣ •  GitͱγεςϜͷঢ়ଶ͕ඞͣ౳͍͠ɺGitΛਅͱ͢Δߟ͑ •  γεςϜΛGit؅ཧ͢Δ GitOps
  27. ·ͱΊ •  Kubernetes্ͷϦιʔε܈΍Load Balancer / GitLab Project ͷ࡞੒ΛAPIΛ௨ͯࣗ͡ಈԽ •  Management

    ConsoleΛఏڙ͠KubernetesΛந৅Խ •  GitLab CIͱ࿈ܞ͠CI/CDΛ࣮ݱ •  ӡ༻͸Gitૢ࡞Ͱ׬݁ͤ͞ಛผͳૢ࡞͸ෆཁ ୭Ͱ΋؆୯ʹ࢖͑ΔϓϥοτϑΥʔϜͱͯ͠KubernetesΛ׆༻
  28. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ