Cloud Native時代における Docker / Kubernetes による開発 Developers Summit 2019 at 02/14 / devsumi2019_amsy810_k8s

Cloud Native時代における Docker / Kubernetes による開発 Developers Summit 2019 at 02/14 / devsumi2019_amsy810_k8s

今日Dockerなどのコンテナ技術は広く普及し、GCP・Azure・AWSがマネージドサービスをリリースしたことなどからも、コンテナオーケストレーションエンジンとしてはKubernetesがデファクトスタンダードだと言えます。
本講演ではKubernetesが必要な理由・機能及びコンセプト・解決できる問題について、また分散システムとしてのKubernetesの仕組みについて紹介します。あわせて、コンテナを利用した開発をするにあたり切り離すことのできない「Cloud Native」や「マイクロサービス」の考え方、最近のKubernetesを取り巻く技術動向、将来性についても紹介します。

青山 真也
株式会社サイバーエージェント
アドテク本部 Infrastructure Engineer
Cloud Native Days Tokyo Co-chair/Japan Container Days実行委員/Cloud Native Meetup Tokyo Organizer/Kubernetes Meetup Tokyo Organizer/KubeCon日本人会 Organizer

株式会社サイバーエージェントアドテク本部。2016年新卒入社。OpenStackを使ったプライベートクラウドやGKE互換なコンテナプラットフォームをゼロから構築し、国内カンファレンスでのKeynoteに登壇。その後、世界で2番目にCertified Kubernetes Application Developer、138番目にCertified Kubernetes Administratorの認定資格を取得。著書に『Kubernetes完全ガイド』。現在はKubernetesやOpenStackなどOSSへのコントリビュート活動をはじめ、Cloud Native Days Tokyo Co-chair、CNCF公式のCloud Native Meetup TokyoのOrganizerやJapan Container Daysの運営などコミュニティ活動にも従事しています。

De266761b955b2636e454a1bc7a99ed4?s=128

Masaya Aoyama (@amsy810)

February 14, 2019
Tweet

Transcript

  1. Masaya Aoyama CyberAgent adtech studio Cloud Native࣌୅ʹ͓͚Δ Docker / Kubernetes

    ʹΑΔ։ൃ Developers Summit 2019 at 02/14 ࢿྉ: http://bit.ly/devsumi 2019 k8s MasayaAoyama @amsy810 Masaya Aoyama CyberAgent adtech studio Cloud Native࣌୅ʹ͓͚Δ Docker / Kubernetes ʹΑΔ։ൃ Developers Summit 2019 at 02/14 MasayaAoyama @amsy810
  2. $58'B@-9C Kubernetes )"  ;: Japan Container Days v18.04 Keynote

    ,&#6(!   .+=4 AWS Dev Day TokyoIBM Think Japan  CKA #138CKAD #2 Masaya Aoyama (@amsy810) Infrastructure Engineer  Co-chair - Cloud Native Days Tokyo B0 Japan Container DaysC Organizer - Cloud Native Meetup Tokyo Organizer - Kubernetes Meetup Tokyo Organizer - KubeCon /1 3! Contribute to OpenStack and Kubernetes 2% KaaS *< / ?7 K8s A>  
  3.   Kubernetes  

  4. Instagramable Kubernetes K

  5. Agenda • Cloud Native and Kubernetes • Microservice and Service

    Mesh • Container and Docker • Kubernetes Overview • What is doing Kubernetes • Kubernetes is Framework and Distributed System • CI/CD with Kubernetes/Docker • Future of Kubernetes
  6. Cloud Native and Kubernetes What is Kubernetes? What is Cloud

    Naitve?
  7. CNCF and The Linux Foundation • Kubernetes The Linux Foundation

    CNCF  •     
  8. Cloud Native Cloud native technologies empower organizations to build and

    run scalable applications in modern, dynamic environments such as public, private, and hybrid clouds. Containers, service meshes, microservices, immutable infrastructure, and declarative APIs exemplify this approach. These techniques enable loosely coupled systems that are resilient, manageable, and observable. Combined with robust automation, they allow engineers to make high-impact changes frequently and predictably with minimal toil. The Cloud Native Computing Foundation seeks to drive adoption of this paradigm by fostering and sustaining an ecosystem of open source, vendor-neutral projects. We democratize state-of-the-art patterns to make these innovations accessible for everyone. CNCF Cloud Native Defenition v1.0, CNCF, 2018-11-28 (https://github.com/cncf/toc/blob/master/DEFINITION.md)
  9. Cloud Native 8 Cloud native technologies empower organizations to build

    and run scalable applications in modern, dynamic environments such as public, private, and hybrid clouds. Containers, service meshes, microservices, immutable infrastructure, and declarative APIs exemplify this approach. These techniques enable loosely coupled systems that are resilient, manageable, and observable. Combined with robust automation, they allow engineers to make high-impact changes frequently and predictably with minimal toil. The Cloud Native Computing Foundation seeks to drive adoption of this paradigm by fostering and sustaining an ecosystem of open source, vendor-neutral projects. We democratize state-of-the-art patterns to make these innovations accessible for everyone. CNCF Cloud Native Defenition v1.0, CNCF, 2018-11-28 (https://github.com/cncf/toc/blob/master/DEFINITION.md) • .0  • & • /- • 4*  • + 3 71 )%5 ($6 " !'2 Open Scalable #,
  10. Kubernetes is key product for Cloud Native Computing Cloud Native

    Ecosystem
  11. None
  12. Cloud Native        

     
  13. Microservice and Service Mesh Benefit of Microservice and Service Mesh

    •  •  •  •  • 
  14. Microservice Architecture     ProductPage Reviews Details Ratings

    HTTP/gRPC HTTP/gRPC HTTP/gRPC Bookinfo Application, Istio, 2018-11-28 (https://istio.io/docs/examples/bookinfo/)
  15. %' )#!D@X_71T gRPC, REST N%' )#!cS 2 )#!@X_7UJ<f "$'9A :

    CT/*"$'1T  f^=eO4; 6YBbK-^  2`aG7%' )#!bK ,+?M CT\-E[L   !)&(9A G7CT!)&(  .IV d8,+F0  G7CTd8Z 53 R] H> )#!PQW  Benefit of Microservice Golang Java Scala gRPC REST
  16. %' )#!D@X_71T gRPC, REST N%' )#!cS 2 )#!@X_7UJ<f "$'9A :

    CT/*"$'1T  f^=eO4; 6YBbK-^  2`aG7%' )#!bK ,+?M CT\-E[L   !)&(9A G7CT!)&(  .IV d8,+F0  G7CTd8Z 53 R] H> )#!PQW  Developer Benefit of Microservice
  17. %' )#!D@X_71T gRPC, REST N%' )#!cS 2 )#!@X_7UJ<f "$'9A :

    CT/*"$'1T  f^=eO4; 6YBbK-^  2`aG7%' )#!bK ,+?M CT\-E[L   !)&(9A G7CT!)&(  .IV d8,+F0  G7CTd8Z 53 R] H> )#!PQW  Benefit of Microservice
  18. %' )#!D@X_71T gRPC, REST N%' )#!cS 2 )#!@X_7UJ<f "$'9A :

    CT/*"$'1T  f^=eO4; 6YBbK-^  2`aG7%' )#!bK ,+?M CT\-E[L   !)&(9A G7CT!)&(  .IV d8,+F0  G7CTd8Z 53 R] H> )#!PQW  Benefit of Microservice
  19. %' )#!D@X_71T gRPC, REST N%' )#!cS 2 )#!@X_7UJ<f "$'9A :

    CT/*"$'1T  f^=eO4; 6YBbK-^  2`aG7%' )#!bK ,+?M CT\-E[L   !)&(9A G7CT!)&(  .IV d8,+F0  G7CTd8Z 53 R] H> )#!PQW  Benefit of Microservice
  20. 500+ microservices The Case of Chaos, Bruce Wong, 2014-12-19, (https://www.slideshare.net/BruceWong3/the-case-for-chaos)

    The History of the Service Mesh, The New Stack, 2018-2-13, (https://thenewstack.io/history-service-mesh/)
  21. 500+ microservices The Case of Chaos, Bruce Wong, 2014-12-19, (https://www.slideshare.net/BruceWong3/the-case-for-chaos)

    The History of the Service Mesh, The New Stack, 2018-2-13, (https://thenewstack.io/history-service-mesh/) Can we get Observability?
  22. Service Mesh Architecture (generally) • Microservice • Microservice with Service

    Mesh Proxy App a Proxy App b Proxy App c App a App b App c
  23. Service Mesh  • Microservice     Proxy

    App a Proxy App b Proxy App c
  24. Service Mesh  • Traffic Shifting (ex, Canary release) Proxy

    App a Proxy App b1 Proxy App b2 99 % 1 %
  25. Service Mesh  • Circuit Break • Fault Injection •

    Rate Limit • Retry • mTLS Proxy App a Proxy App b Proxy App c #% !$ &) , *'(  + ")
  26. Microservice / Service Mesh  Microservice .H:LB7 &=, 2O 16()FPN0Q

    Service Mesh #@ … • Microservice M )I;5C 9J K! $3/> 8*(/> • AE+  • 4"% • D? • )I; • -< G'(
  27. Micro Service   VM   …

  28. Container / Docker Benefit of Container / Docker • 

    •   • 
  29. Container System Container • KVMXen  •  init Application

    Container •     •   
  30. Docker • Docker4%Application Container .71- +8$! • #DevOps/# 2: /3

     6)*5 • 0, Moby"  &9  # containerd ('
  31. Dockerfile  Docker Image FROM centos:7 RUN yum -y install

    epel-release RUN yum -y install nginx COPY nginx.conf /etc/nginx/ ENTRYPOINT ["nginx", "-g", "daemon off;"] Build Once, Run Anywhere   Docker Image Dockerfile
  32. $ docker build . -t sample-image Sending build context to

    Docker daemon 252.9kB Step 1/5 : FROM centos:7 ---> 75835a67d134 75835a67d134 sample-image
  33. $ docker build . -t sample-image Sending build context to

    Docker daemon 252.9kB Step 1/5 : FROM centos:7 ---> 75835a67d134 Step 2/5 : RUN yum -y install epel-release ---> Running in 9db248fc7b9a ... Removing intermediate container 9db248fc7b9a ---> 2fe5a7f8c007 75835a67d134 2fe5a7f8c007 sample-image
  34. $ docker build . -t sample-image Sending build context to

    Docker daemon 252.9kB Step 1/5 : FROM centos:7 ---> 75835a67d134 Step 2/5 : RUN yum -y install epel-release ---> Running in 9db248fc7b9a ... Removing intermediate container 9db248fc7b9a ---> 2fe5a7f8c007 Step 3/5 : RUN yum -y install nginx ---> Running in 0547bd920b0a ... Removing intermediate container 0547bd920b0a ---> 843b47a96c5e 75835a67d134 2fe5a7f8c007 843b47a96c5e sample-image
  35. $ docker build . -t sample-image Sending build context to

    Docker daemon 252.9kB Step 1/5 : FROM centos:7 ---> 75835a67d134 Step 2/5 : RUN yum -y install epel-release ---> Running in 9db248fc7b9a ... Removing intermediate container 9db248fc7b9a ---> 2fe5a7f8c007 Step 3/5 : RUN yum -y install nginx ---> Running in 0547bd920b0a ... Removing intermediate container 0547bd920b0a ---> 843b47a96c5e Step 4/5 : COPY nginx.conf /etc/nginx/ ---> fe63b2d4c95d 75835a67d134 2fe5a7f8c007 843b47a96c5e fe63b2d4c95d sample-image
  36. $ docker build . -t sample-image Sending build context to

    Docker daemon 252.9kB Step 1/5 : FROM centos:7 ---> 75835a67d134 Step 2/5 : RUN yum -y install epel-release ---> Running in 9db248fc7b9a ... Removing intermediate container 9db248fc7b9a ---> 2fe5a7f8c007 Step 3/5 : RUN yum -y install nginx ---> Running in 0547bd920b0a ... Removing intermediate container 0547bd920b0a ---> 843b47a96c5e Step 4/5 : COPY nginx.conf /etc/nginx/ ---> fe63b2d4c95d Step 5/5 : ENTRYPOINT ["nginx", "-g", "daemon off;"] ---> Running in 876ee4d29339 Removing intermediate container 876ee4d29339 ---> b5068171c053 75835a67d134 2fe5a7f8c007 843b47a96c5e fe63b2d4c95d b5068171c053 sample-image
  37. Docker  •     •  Read

    Write •  Read Only
  38.     5: ENTRYPOINT [”/usr/sbin/nginx", "-g", "daemon off;"]

    5: ENTRYPOINT [”nginx", "-g", "daemon off;"]    
  39. Ref: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ Ref: https://12factor.net/ B*=C Part of Docker Container Best

    Practice •  @( 1 • "3<  $1BImmutable InfrastructureC • A;8, / 4:8,+" !'9 • #0> ! &  • 59)?.% 8,-2 / 7 •   6  • etc
  40. Container / Docker  VM0 … •  #(+. •

    7':8 • ##,  • /6 %9;=">=!< • Immutable Infrastructure *1 • 35)  • -$& • 42
  41.   

  42. Kubernetes Overview Promote Cloud Native •  •  •

     •  • 
  43. Docker Swarm mode Container Orchestration Engine

  44. Container Orchestration Engine (4/0 • 3*Docker2/ • # $ #

    •  $ # / $ $ # • "$ # $ • #-.15 • 6&+!$ # • $ • "$# # • $,')%2/
  45. Container Orchestration Engine CY OP • XE Docker*" SO •

    1 $ ,2.1 • 2.1 / 2"2.1 • 02.1)!2" • 1 $ KLRZ • ^>F /(&2.1 • 2'!%. • 02#%-11 • !2J?D; SO Container Orchestration Engine CY OP • QT9  + • B34 • SO • 8[M  • :N W67 _U IA \ H@] 54 = <G 8V
  46. CNCFStandardization 01.     " (!) OCI v1.0

    02.     #  CRI 03.   #  CSI 04. #  CNI
  47.   Kubernetes Docker   Kubernetes   

    •    CRI   • docker • cri-o • containerd OCI   • runC • gVisor • Kata Containers • Nabla Containers • Firecracker # )!  '(    $"&%
  48. What is doing Kubernetes? Declarative Code & APIs Self-Healing Automation

    & Immutable Infrastructure
  49. Kubernetes  Design Principles, Kubernetes Community, 2017-11-04 (https://github.com/kubernetes/community/blob/master/contributors/design-proposals/architecture/principles.md) 02 03

    01 Self Healing  ) #"  Automation & Immutable Infrastructure Immutable Infrastructure& # Declarative Code & API  Manifests$" %'API !( Infrastructure as Code
  50. Declarative Code and APIs Developer Register YAML Manifest Kubernetes Cluster

    Manifests API  Infrastructure as Code $ kubectl apply –f manifest.yaml
  51. Pod       

  52.        Load Balancer

  53. ReplicaSet  Self-Healing • ReplicaSet  Replica  • =

    Node  Node
  54. ReplicaSet  Rolling Update (Automation) • #%"$ /) • $!%

    % • Immutable Infrastructure • #%"$ .& Load Balancer Developer (,   '* Deployment+-
  55. ReplicaSet  Rolling Update (Automation) •   • 

        • Immutable Infrastructure •   Load Balancer
  56. ReplicaSet  Rolling Update (Automation) •   • 

        • Immutable Infrastructure •   Load Balancer
  57. ReplicaSet  Rolling Update (Automation) •   • 

        • Immutable Infrastructure •   Load Balancer
  58. Key points • KubernetesGoogle=/A3.  + #(&$,'Borg%,OSS1  → ;*,),"25<>1

     ?01846 • 7@1 $!*,9-YAML:  → Infrastructure EngineerBOpsC . Server-side Engineer BDevC.
  59. Kubernetes is Framework and Distributed System Custom Resource Definition

  60.  Kubernetes Developer     

  61.  Kubernetes Developer   !!! ! !  

      
  62.  Kubernetes Developer  !$ % % %%% 1. "

    2.  # 3.   → Control Loop
  63. … Developer  -1 0+) &' )  ! )

      1. +*# .( 2. +*#,"*# %/ 3. , $ → Control Loop
  64. ReplicaSet  *2 + Developer  18 Pod (36 #4

    $Pod ' 9 Pod ' 9 1. / .&5- 2. / .&0%.&,7 3. " ! 0 ) → Control Loop
  65. Custom Resource Definition Developer      1.

     2.  3.    → Control Loop
  66. Custom Resource Definition Developer      

    
  67. Custom Resource Definition Developer   Kubernetes Pod  Queue

     
  68. Kubernetes is more extensible C A D C DBC B

    DA C A C A A F A D2 F C C BB & A BB C A C A C DBC A & A C 2 A CB A A A & B A AD B &B C D C C DC C C 2 Kubernetes       Boring Kubernetes 
  69. Kubernetes is more extensible B C B CAB A C

    2 B B AA & AA 2F B B B D CAB & D 2 B 2BA D 2 & A C A2 &A B C B B 2F CB B B
  70. CI/CD with Kubernetes / Docker How to build a CI/CD

    Pipelines?
  71. GitOps Overview        CI

    CD    Kubernetes  D Developer GitOps, Weaveworks, 2018-11-28 (https://www.weave.works/technologies/gitops/)
  72. GitOps – PR       CD

    Kubernetes 
  73. GitOps - Staging     (staging)  

     CI CD    Staging  D Developer staging branch master branch     (production) Production 
  74. GitOps - Production     (staging)  

     CI CD    D Developer staging branch master branch     (production) Staging  Production 
  75. GitOps     (staging)    CI

    CD    Developer staging branch master branch     (production) Staging  T Production  R R S !$%& #  "  $ E E R R S ""%&  !%&
  76. Future of Kubernetes Kubernetes is becoming de-facto standard in the

    future?
  77. KubeCon + CloudNativeCon KubeCon + CloudNativeCon Barcelona 2019 Call for

    Proposals (CFP) Is Open, CNCF, 2018-11-28 (https://www.cncf.io/blog/2018/11/16/kubecon-barcelona-2019-call-for-proposals-cfp-is-open/)
  78. Google Kubernetes Engine Managed Kubernetes Serivce Azure Kubernetes Service 2014-11

    2017-02 2017-11 Amazon Elastic Container Service for Kubernetes
  79. Kubernetes for Enterprise •      

    Monzo Bank • Kubernetes + Linkerd (Service Mesh) Building a Modern Bank Backend, Monzo Bank Ltd, 2018-11-28 (https://monzo.com/blog/2016/09/19/building-a-modern-bank-backend/)
  80. CNCFStandardization 01.     " (!) OCI v1.0

    02.     #  CRI 03.   #  CSI 04. #  CNI
  81. CNCF Community Presentation, CNCF, 2018 (https://github.com/cncf/presentations)

  82. Kubernetes  

  83. 3 I H uNs P /D 6 IBK c a

    io sy P   0 C 1 DD 3 I H W3 I HS M 3 I H & 72 uNs C ID 9 CD H uNs 0BH K L 4 uNs / B 8I uNs /D HI uNs 5 I I uNs uNs N snN s h l o y f fl y s N snr N tk ye & hs c N uNsu ghd v o y /2 /0 fl N s 8 KB 5 HA 3 I H dNkyl 3 I H b
  84. https://bit.ly/cndt2019cfp Cloud Native Days Tokyo  : Japan Container Days

    @amsy810      CFP
  85. Thank you for your attention follow me: @amsy810