Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong, DevOps - Branch Manager at GMO Zcom VietNam Lab Center

99 views

Published on

Kubernetes is a platform used to automate the management, to scale and to deploy applications in the form of containers. Kubernetes is also called Container orchestration engine.

Published in: Technology
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong, DevOps - Branch Manager at GMO Zcom VietNam Lab Center

  1. 1. Kubernetes trong triển khai ứng dụng web Nguyen Xuan Phong
  2. 2. Agenda  Giới thiệu  Nhắc lại về Docker  Giới thiệu Kubernetes  Kiến trúc Kubernetes  Các thành phần cơ bản trong Kubernetes  Rancher 2.0  Harbor – Docker registry  Demo
  3. 3. $ NGUYEN XUAN PHONG $ $ DevOps – Branch Manager at GMO Zcom VietNam Lab Center $ $ Web - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ Php $ Java $ Javascript $ $ Operation - - - - - - - - - - - - - - - - - - - - - - - - - $ Linux $ Vagrant $ Ansible $ Docker $ Kubernetes $ $ BrSE - - - - - - - - -- - - - - - - - - - - - - - - -- - - - $ Japanese N2
  4. 4. https://point.gmo.jp/
  5. 5. Agenda  Giới thiệu  Nhắc lại về Docker  Giới thiệu Kubernetes  Kiến trúc Kubernetes  Các thành phần cơ bản trong Kubernetes  Rancher 2.0  Harbor – Docker registry  Demo
  6. 6. Vấn đề trong triển khai hệ thống phần mềm
  7. 7. m n
  8. 8. Giải pháp triển khai hệ thống phần mềm
  9. 9. m
  10. 10. Docker xuất hiện mở ra cuộc cách mạng về ảo hoá
  11. 11. So sánh với các HyperVisor
  12. 12. HyperVisor Type 2 Docker Virtualization Type Vitualization Machine Container Weight of the created virtual systems Heavy Very lightweight Startup time for created machine A few minutes A few seconds Isolation level for created vitural systems Full Partial Guaranteed Resources at Hardware Level ? Yes No Can create machines with different OS ? Yes No
  13. 13. Kiến trúc Docker
  14. 14. Nginx Php - fpm Mysql Docker Container Simple web app
  15. 15. Các vấn đề liên quan đến triển khai hệ thống sử dụng docker Health Discovery Scheduling Configuration Scaling Security There are more! Monitoring
  16. 16. Agenda  Bối cảnh  Nhắc lại về Docker  Giới thiệu Kubernetes  Kiến trúc Kubernetes  Các thành phần cơ bản trong Kubernetes  Rancher 2.0  Harbor – Docker registry  Demo
  17. 17. κυβερνήτης
  18. 18. k8s
  19. 19. Kubernetes  Manage application, not machine  Kubernetes là một Platform tự động hoá việc quản lý, scaling container  Kubernetes còn gọi là Container orchestration engine.  Kubernetes by Google dựa trên kinh nghiệm quản lý sử dụng các container
  20. 20. =
  21. 21. Kubernetes vs Docker Swarm https://platform9.com/blog/kubernetes-docker-swarm-compared/
  22. 22. Kubernetes làm được những gì  Việc quản lý hàng loạt docket host  Container Scheduling  Rolling update  Scaling/Auto Scaling  Monitor vòng đời và tình trạng sống chết của container.  Self-healing trong trường hợp có lỗi xãy ra. (Có khả năng phát hiện và tự correct lỗi)  Service discovery  Load balancing  Quản lý data  Quản lý work node  Quản lý log  Infrastructure as Code  Sự liên kết và mở rộng với các hệ thống khác
  23. 23. Kubernetes liên kết với hệ sinh thái  Ansible: Deploy container tới Kubernetes  Apache Ignite: Sử dụng Service Discovery của Kubernetes, tự động tạo và scaling k8s clkuster  Fluentd: gửi log của container trong Kubernetes  Jenkins: Deploy container đến Kubernetes  OpenStack:Cấu trúc k8s liên kết với Cloud  Prometheus: Monitor Kubernetes  Spark: Thực thi native job trên Kubernetes(thay thế cho YARN)  Spinnaker:Deploy container đến Kubernetes  v.v
  24. 24. Các môi trường Kubernetes  Local Kubermetes  Công cụ hỗ trợ thiết lập môi trường Kubernetes  Quản lý Kubernetes trên public cloud
  25. 25. Local Kubermetes Minikube Docker for Mac
  26. 26. Công cụ hỗ trợ thiết lập môi trường Kubernetes  kubeadm  Rancher
  27. 27. Quản lý Kubernetes trên public cloud  Google Kubernetes Engine(GKE)  Azure Container Service(AKS)  Elastic Container Service for Kubernetes(EKS) GKE AKS
  28. 28. GKE(Google Kubernetes Engine)
  29. 29. Agenda  Giới thiệu  Nhắc lại về Docker  Giới thiệu Kubernetes  Kiến trúc Kubernetes  Các thành phần cơ bản trong Kubernetes  Rancher 2.0  Harbor – Docker registry  Demo
  30. 30. Agenda  Giới thiệu  Nhắc lại về Docker  Giới thiệu Kubernetes  Kiến trúc Kubernetes  Các thành phần cơ bản trong Kubernetes  Rancher 2.0  Harbor – Docker registry  Demo
  31. 31. Node
  32. 32. Hosts running k8s daemons
  33. 33. Node Node Node Master API Scheduler etc.. kubelet kubelet kubelet
  34. 34. Kubernetes Resource Phân Loại Resource Mô tả Workloads Resource liên quan đến thực thi container Discovery&Load balancer Resource cung cấp Endpoint - cho phép truy cập Container từ bên ngoài Cluster Config&Storage Resources liên quan đến settings, confidential information, persistent volumes vv Cluster Resources liên quan đến security và quota Metadata Resource cho việc quản lý Resource
  35. 35. Workloads Pod ReplicationController ReplicaSet Deployment DaemonSet StatefulSet Job CronJob Discovery&LB resource Service ClusterIP NodePort LoadBalancer ExternalIP ExternalName Headless Ingress Config&Storage Secret ConfigMap PersistentVolumeClaim Cluster resource Namespace ServiceAccount Role ClusterRole RoleBinding ClusterRoleBinding NetworkPolicy ResourceQuota PersistentVolume Node Metadata resource CustomResourceDefinition LimitRange HorizontalPodAutoscaler
  36. 36. Workloads Pod ReplicationController ReplicaSet Deployment DaemonSet StatefulSet Job CronJob Discovery&LB resource Service ClusterIP NodePort LoadBalancer ExternalIP ExternalName Headless Ingress Config&Storage Secret ConfigMap PersistentVolumeClaim Cluster resource Namespace ServiceAccount Role ClusterRole RoleBinding ClusterRoleBinding NetworkPolicy ResourceQuota PersistentVolume Node Metadata resource CustomResourceDefinition LimitRange HorizontalPodAutoscaler Application Developer normally use 3 types
  37. 37. Workloads Pod ReplicationController ReplicaSet Deployment DaemonSet StatefulSet Job CronJob Discovery&LB resource Service ClusterIP NodePort LoadBalancer ExternalIP ExternalName Headless Ingress Config&Storage Secret ConfigMap PersistentVolumeClaim
  38. 38. Pod
  39. 39. Basic unit of deployment in k8s
  40. 40. Group of container
  41. 41. Container configuration
  42. 42. Shared storage
  43. 43. Pod container container container Volume NIC
  44. 44. Pod container container container nginx frontend app redis/cache e.g.
  45. 45. Scheduled together
  46. 46. Guaranteed to be on the same node
  47. 47. container container container container container container container container container Node Node Node Pod Pod Pod
  48. 48. container container container container container container Node 1 Node 2 Node 3 Pod Pod container container container Pod container container container Pod container container container Pod container container container Pod container container container Pod Depends on each node’s resource availability and each pod’s resource requirement
  49. 49. container container container Node Node
  50. 50. container container container Node Node This will NEVER happen
  51. 51. MasterAPI UI CLI Node 1 Node 2 Node 3 Pod
  52. 52. Pod Node MasterAPI UI CLI Node 1 Node 2 Node 3 Pod =
  53. 53. Demo Pod
  54. 54. ReplicaSet
  55. 55. Keep track of Pod replicas
  56. 56. Replica Set replica: 3 template: container container container Pod A container container container Pod
  57. 57. Replica Set replica: 3 template: container container container Pod B container container container Pod A container container container Pod
  58. 58. Replica Set replica: 3 template: container container container Pod B container container container Pod A container container container Pod C container container container Pod
  59. 59. Replica Set container container container Podreplica: 3 template: container container container Pod B container container container Pod A container container container Pod C
  60. 60. Replica Set replica: 3 template: container container container Pod B container container container Pod A container container container Pod D container container container Pod
  61. 61. Auto healing
  62. 62. Deployment
  63. 63. Manages Replicas Set state transitions
  64. 64. Deployment container container container Podreplica: 3 template:
  65. 65. Deployment ReplicaSet A container container container Pod replica: 3 template: container container container Podreplica: 3 template:
  66. 66. Deployment ReplicaSet A containe r containe r containe r Pod replica: 3 template: Change some setting, please! container container container Podreplica: 3 template:
  67. 67. Deployment ReplicaSet A Change some setting, please! replica: 3 template: container container container Podreplica: 3 template: container container container Pod replica: 3 template:
  68. 68. Deployment ReplicaSet A Change some setting, please! ReplicaSet B replica: 3 template: container container container Podreplica: 3 template: container container container Pod replica: 3 template: container container container Pod replica: 3 template:
  69. 69. Deployment ReplicaSet A Change some setting, please! ReplicaSet B replica: 3 template: container container container Podreplica: 3 template: container container container Pod replica: 3 template:
  70. 70. Deployment ReplicaSet B replica: 3 template: container container container Podreplica: 3 template: container container container Pod replica: 3 template:
  71. 71. Keep track of state change history
  72. 72. Deployme nt ReplicaSet B replica: 3 template: container container container Pod replica: 3 template: container container container Podreplica: 3 template:
  73. 73. Deployment Oh wait, I actually didn’t want to do that ReplicaSet B replica: 3 template: container container container Pod replica: 3 template: container container container Podreplica: 3 template:
  74. 74. Deployment Oh wait, I actually didn’t want to do that ReplicaSet B Rollback container container container Pod replica: 3 template: container container container Podreplica: 3 template:
  75. 75. Deployment ReplicaSet A ReplicaSet B Oh wait, I actually didn’t want to do that Rollback container container container Pod replica: 3 template: container container container Podreplica: 3 template: container container container Pod replica: 3 template:
  76. 76. Deployment ReplicaSet A ReplicaSet B Oh wait, I actually didn’t want to do that Rollback container container container Podreplica: 3 template: container container container Pod replica: 3 template:
  77. 77. Deployment ReplicaSet A container container container Podreplica: 3 template: container container container Pod replica: 3 template:
  78. 78. Rolling update Pod
  79. 79. DaemonSet
  80. 80. DaemonSet: Schedule Pod một cách tuần tự từng Pod một trên tất cả các Node.  Use case  Fluentd: Collect logs tool  Datadog: Monitoring tool
  81. 81. Job
  82. 82. Job = Pod + batch = env + batch  Job  Start Pod (container centos)  Run command: sleep 60;  Finish
  83. 83.  restartPolicy  OnFailure: Use this Pod to run job again  Never: Create new Pod if Pod had problem and run job
  84. 84.  completions: 1  Job success one time and finish  parallelism: 1  run parallelism 1 pod  backoffLimit: 10  Allows failing 10 times
  85. 85. Run job one time
  86. 86. CronJob
  87. 87. Cronjob = Job + schedule Crontab = batch + schedule
  88. 88. Cronjob = Job + schedule 1 2 3
  89. 89. Cronjob = Job + schedule  schedule  same cron format  http://www.nncron.ru/help/EN/working/cron -format.htm  Setting  concurrencyPolicy  Allow(default): Không hạn chế đối với việc thực thi đồng thời  Forbid: Job trước đó thực hiện chưa xong thì không tạo Job mới.(không thực hiện đồng thời)  Replace: Trong trường hợp Job cũ đang chạy, huỷ Job cũ và tạo Job mới 1 2 3
  90. 90. Cronjob = Job + schedule  schedule  Setting  startingDeadlineSeconds  Thời gian trễ cho phép để run job  successfulJobsHistoryLimit  Số lượng Job thành công được duy trì  failedJobsHistoryLimit  Số lượng Job thất bại duy trì.  Job 1 2 3
  91. 91. K8s Cronjob vs cron job in linux
  92. 92. Problem in cron job in linux Job
  93. 93. Problem in cron job in linux Job That’s OK ??? Job
  94. 94. Solution with K8s Cronjob Job Node 1 Node 2
  95. 95. Solution with K8s Cronjob Job Node 1 Node 2
  96. 96. Solusion with K8s Cronjob Node 1 Node 2 Job
  97. 97. Workloads Pod ReplicationController ReplicaSet Deployment DaemonSet StatefulSet Job CronJob Discovery&LB resource Service ClusterIP NodePort LoadBalancer ExternalIP ExternalName Headless Ingress Config&Storage Secret ConfigMap PersistentVolumeClaim
  98. 98. Workloads Pod ReplicationController ReplicaSet Deployment DaemonSet StatefulSet Job CronJob Discovery&LB resource Service ClusterIP NodePort LoadBalancer ExternalIP ExternalName Headless Ingress Config&Storage Secret ConfigMap PersistentVolumeClaim
  99. 99. Kubernetes network
  100. 100. ClusterIP
  101. 101. ClusterIP Service :80 :80 :80
  102. 102. ExternalIP
  103. 103. :80 :80 :80 ExtenalIP Service
  104. 104. NodePort
  105. 105. :80 :80 :80 NodePort Service
  106. 106. :80 :80 :80 NodePort Service
  107. 107. NodePort Service
  108. 108. NodePort Service
  109. 109. LoadBalancer
  110. 110. Load Balancer Service
  111. 111. LoadBalancer support for GKE AKS
  112. 112. Loadbalancer for my K8s ??? https://www.weave.works/blog/kubernetes-faq-how- can-i-route-traffic-for-kubernetes-on-bare-metal
  113. 113. MetalLB https://metallb.universe.tf/
  114. 114. Workloads Pod ReplicationController ReplicaSet Deployment DaemonSet StatefulSet Job CronJob Discovery&LB resource Service ClusterIP NodePort LoadBalancer ExternalIP ExternalName Headless Ingress Config&Storage Secret ConfigMap PersistentVolumeClaim
  115. 115. Agenda  Bối cảnh  Nhắc lại về Docker  Giới thiệu Kubernetes  Kiến trúc Kubernetes  Các thành phần cơ bản trong Kubernetes  Rancher 2.0  Harbor – Docker registry  Demo
  116. 116. Rancher is redesigned to work on Kubernetes.
  117. 117. Rancher 2.0
  118. 118. Agenda  Bối cảnh  Nhắc lại về Docker  Giới thiệu Kubernetes  Kiến trúc Kubernetes  Các thành phần cơ bản trong Kubernetes  Rancher 2.0  Harbor – Docker registry  Demo
  119. 119. Docker registry
  120. 120. Docker registry
  121. 121. Docker registry
  122. 122. Kiến trúc Harbor
  123. 123. Kiến trúc Harbor
  124. 124. MasterAPICLI
  125. 125. MasterAPICLI Kube-demo CLI Push images
  126. 126. MasterAPICLI Kube-demo code-pvc 2G nginx-config- pvc 1G CLI
  127. 127. MasterAPICLI Kube-demo code-pvc 2G CLInginx-config- pvc 1G
  128. 128. MasterAPICLI Kube-demo code-pvc 2G CLI Pull images nginx-config- pvc 1G
  129. 129. MasterAPICLI Pull images NIC NIC code-pvc 2G NodePort *:32253 Pod (nginx, php-fpm) Volume Kube-demo nginx-config- pvc 1G DB
  130. 130. MasterAPICLI Pull images NIC NIC code-pvc 2G NodePort *:32253 Pod (nginx, php-fpm) Volume Kube-demo nginx-config- pvc 1G DB Frontend
  131. 131. MasterAPICLI Pull images NIC NIC code-pvc 2G NodePort *:32253 Pod Volume Kube-demo nginx-config- pvc 1G DB Frontend Backend
  132. 132. MasterAPICLI Pull images NIC NIC NodePort *:32253 Images code-pvc 2G nginx-config- pvc 1G DB Frontend Backend Pod Volume NIC NIC Elasticsearch Kibana Design Security
  133. 133. MasterAPICLI Pull images NIC NIC NodePort *:32253 Images code-pvc 2G nginx-config- pvc 1G DB Frontend Backend Pod Volume NIC NIC Elasticsearch Kibana Design Security
  134. 134. Workloads Pod ReplicationController ReplicaSet Deployment DaemonSet StatefulSet Job CronJob Discovery&LB resource Service ClusterIP NodePort LoadBalancer ExternalIP ExternalName Headless Ingress Config&Storage Secret ConfigMap PersistentVolumeClaim Cluster resource Namespace ServiceAccount Role ClusterRole RoleBinding ClusterRoleBinding NetworkPolicy ResourceQuota PersistentVolume Node Metadata resource CustomResourceDefinition LimitRange HorizontalPodAutoscaler Application Developer normally use 3 types
  135. 135. Kubernetes For Beginner Docker Docker-compose K8s
  136. 136. Tài Liệu Tham Khảo  https://kubernetes.io/docs/tutorials/  Serial blog kubernetes  https://blog.vietnamlab.vn/2018/09/25/nhap-mon- kubernetes-gioi-thieu-rerial-kubernetes/  https://github.com/gmo-vietnamlab/kubernetes- research-demo

×