SlideShare a Scribd company logo
How to Achieve Canary
Deployment on Kubernetes
JohnChen
2019/11/30
Hello Everyone, My name is John
I was
• a System engineer
• a DevOps
I am
• a Site Reliability Engineer
1
Outline
• AWS Elastic Beanstalk
• Kubernetes
• Blue/Green deployment
• Canary deployment
• Component relationship
• Labels in Service and Deployment
• Kubernetes canary deployment
• Helm
• Jenkins
• Conclusions
• Questions
2
AWS Elastic Beanstalk
• AWS Elastic Beanstalk 是在 AWS 上啟動和執行 Web應用程式最快
也最簡單的方法。開發人員只要上傳他們的應用程式碼,服務就
會自動處理所有細節,如資源佈建、負載平衡、自動調整規模和
監控
• Elastic Beanstalk 最適合搭配您的 PHP、Java、Python、Ruby、
Node.js、.NET、Go 或 Docker Web 應用程式使用。Elastic
Beanstalk 可使用核心 AWS 服務,例如 Amazon EC2、Amazon
Elastic Container Service (Amazon ECS)、Auto Scaling 和 Elastic Load
Balancing,輕鬆支援需要擴展到服務數百萬位使用者的應用程式
3
Kubernetes (K8s)
• Kubernetes (K8s) is an open-source system for automating
deployment, scaling, and management of containerized applications.
• It groups containers that make up an application into logical units for
easy management and discovery. Kubernetes builds upon 15 years of
experience of running production workloads at Google, combined
with best-of-breed ideas and practices from the community.
4
Blue Green Deployment 1/3
• 藍綠部署是版本 B 同等數量的被並排部署在版本A旁邊。
• 當新版本滿足上線條件的測試後,流量在負載均衡層從版本 A 切
換到版本 B。
5
Blue Green Deployment 2/3
6
Blue Green Deployment 3/3
1. 連線是有狀態的
2. 變動是不相容於舊版本的
3. 叢集系統
4. 有持久性的資料儲存
7
Canary Deployment 1/3
• 金絲雀部署是指逐漸將生產環境流量從版本 A 切換到版本 B。
• 通常流量是按比例分配的。
• 例如:90% 的請求流向版本 A,10% 的流向版本 B。
8
Canary Deployment 2/3
9
Canary Deployment 3/3
1. 連線是無狀態的
2. 沒有 QA 進行測試
3. 服務之間的流量和延時問題
4. 大量併發時才會發現的問題
10
Original Deployment 1/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 100
green.chen.idv weight 0
Original Version
New Version
11
Original Deployment 2/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 100
green.chen.idv weight 0
staging.chen.idv staging.chen.idv
New Version
Original Version
Functional testing
12
Original Deployment 3/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 95
green.chen.idv weight 5
Original Version
New Version
13
Original Deployment 4/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 90
green.chen.idv weight 10
Original Version
New Version
14
Original Deployment 5/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 75
green.chen.idv weight 25
Original Version
New Version
15
Original Deployment 6/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 50
green.chen.idv weight 50
Original Version
New Version
16
Original Deployment 7/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 25
green.chen.idv weight 75
Original Version
New Version
17
Original Deployment 8/8
www.chen.idv
www.chen.idv
blue.chen.idv weight 0
green.chen.idv weight 100
Original Version
New Version
18
Component relationship
Pod Container
PodReplicaSet
ReplicaSetDeployment
ServiceDeployment
1 N
N
N
N
1
1
1
19
Service Deployment1 N
Kubernetes canary deployment
You can tweak the number of replicas of the stable and canary releases to determine the ratio of
each release that will receive live production traffic (in this case, 3:1). Once you’re confident, you
can update the stable track to the new application release and remove the canary one.
20
Production Pod
metadata.labels:
app. envrionment: preprod
app.service: production
Production Pod
metadata.labels:
app. envrionment: production
app.service: production
Staging Deployment
spec.template.metadata.labels:
app.envrionment: staging
app.service: staging
Preprod Deployment
spec.template.metadata.labels:
app.envrionment: preprod
app.service: production
Production Deployment
spec.template.metadata.labels:
app.envrionment: production
app.service: production
Labels in Service and Deployment
Production Service
selector:
app.service: production
Staging Service
selector:
app.service: staging
Staging Pod
metadata.labels:
app. envrionment: staging
app.service: staging
21
Kubernetes canary deployment 1/6
22
Kubernetes canary deployment 2/6
23
Kubernetes canary deployment 3/6
24
Kubernetes canary deployment 4/6
25
Kubernetes canary deployment 5/6
26
Kubernetes canary deployment 6/6
27
Questions
• 原來用三個 deployment 和兩個 service 就可以達成金絲雀部署了
• 但每一次都用改 yaml 檔案, 再執行 kubectl apply –f xxx
• 這樣操作很複雜,會不會下錯指令?
• 有辦法讓 Developer 自己部署嗎?
28
The Four
29
Helm
• Helm helps you manage Kubernetes applications.
• Helm Charts help you define, install, and upgrade even the most
complex Kubernetes application.
30
Helm Chart
31
Jenkins
• 是一款由Java編寫的開源的持續整合工具。在與Oracle發生爭執後,專案從Hudson
專案復刻。
• 提供了軟體開發的持續整合服務。它執行在Servlet容器中(例如Apache Tomcat)。
它支援軟體組態管理(SCM)工具,可以執行基於Apache Ant和Apache Maven的專
案,以及任意的Shell指令碼和Windows批次處理命令。Jenkins的主要開發者是川口
耕介。Jenkins是在MIT許可證下發布的自由軟體。
32
Jenkins pipeline view
33
Kubernetes Canary Deployment 1/6
34
Kubernetes Canary Deployment 2/6
35
Kubernetes Canary Deployment 3/6
36
Kubernetes Canary Deployment 4/6
37
Kubernetes Canary Deployment 5/6
38
Kubernetes Canary Deployment 6/6
39
Conclusions
40
• Script 可以做到的事,Jenkins 就可以做到
• 要做 CI/CD 需要使用很多工具,但不要被工具限制
• 方法不在新舊,在於有用
• 先站穩腳跟,再向前邁進
Questions
• 為何 preprod pod 和 production pod 在和 1:1 時就切換 ?
• 為何流量還是沒有平均分配?
• 為何不用 ingress?
• 為何不用 Jenkins pipeline ?
41
Q&A
42
Redis Server
6381 port
Redis Server
6379 port
Redis Server
6382 port
Redis Server
6380 port
client-testing-redis.chen.idv
AP 1 AP 2 AP 3 AP 4
EC2
Multi Redis Server in One VM
Redis Server
6379 port
Redis Server
6379 port
Redis Server
6379 port
Redis Server
6379 port
AP 1 AP 2 AP 3 AP 4
client-testing-redis.chen.idv:6381
client-testing-redis.chen.idv:6382
client-testing-redis.chen.idv:6379
client-testing-redis.chen.idv:6380
Kubernetes Pod
Kubernetes Service
One Service Connect to Multi Pod 1/2
Redis Service
selector:
app.service: redis
port:
- name: redis-6379
port: 6379
protocol: TCP
targetPort: redis-6379
- name: redis-6380
port: 6380
protocol: TCP
targetPort: redis-6380
- name: redis-6381
port: 6381
protocol: TCP
targetPort: redis-6381
- name: redis-6382
port: 6382
protocol: TCP
targetPort: redis-6382
Redis Pod 6379
metadata.labels:
app.service: redis
port:
- containerPort: 6379
name: redis-6379
protocol: TCP
Redis Pod 6380
metadata.labels:
app.service: redis
port:
- containerPort: 6379
name: redis-6380
protocol: TCPRedis Pod 6381
metadata.labels:
app.service: redis
port:
- containerPort: 6379
name: redis-6381
protocol: TCP
Redis Pod 6382
metadata.labels:
app.service: redis
port:
- containerPort: 6379
name: redis-6382
protocol: TCP
One Service Connect to Multi Pod 2/2

More Related Content

PDF
Introduction of eBPF - 時下最夯的Linux Technology
PDF
Introduction to CircleCI
PPTX
Introduction kubernetes 2017_12_24
PPTX
KubeCon EU 2016: Multi-Tenant Kubernetes
PDF
Network plugins for kubernetes
PDF
K8s storage-glusterfs-20180210
PDF
Load Balancing 101
PPTX
Introduction to CNI (Container Network Interface)
Introduction of eBPF - 時下最夯的Linux Technology
Introduction to CircleCI
Introduction kubernetes 2017_12_24
KubeCon EU 2016: Multi-Tenant Kubernetes
Network plugins for kubernetes
K8s storage-glusterfs-20180210
Load Balancing 101
Introduction to CNI (Container Network Interface)

What's hot (20)

PDF
KubeCon EU 2016: Killing containers to make weather beautiful
PDF
Automatically Renew Certificated In Your Kubernetes Cluster
PPTX
Monitoring, Logging and Tracing on Kubernetes
PDF
Kubernetes persistence 101
PPTX
Kubernetes service with ha
PPTX
Kubernetes Networking 101
PDF
Deep dive in container service discovery
PDF
PPTX
[20200720]cloud native develoment - Nelson Lin
PPTX
Kubernetes - State of the Union (Q1-2016)
PDF
DockerCon EU 2015: The Glue is the Hard Part: Making a Production-Ready PaaS
PDF
Overview of kubernetes network functions
PDF
Kubernetes on the Edge / 在邊緣的K8S
PDF
Docker Summit 2016 - Kubernetes: Sweets and Bitters
PPTX
Lifecycle of a pod
PDF
Kubernetes - Starting with 1.2
PDF
Kubernetes meetup 101
PDF
Kubernetes Day 2017 - Build, Ship and Run Your APP, Production !!
PDF
How to integrate Kubernetes in OpenStack: You need to know these project
PDF
Kubernetes 架構與虛擬化之差異
KubeCon EU 2016: Killing containers to make weather beautiful
Automatically Renew Certificated In Your Kubernetes Cluster
Monitoring, Logging and Tracing on Kubernetes
Kubernetes persistence 101
Kubernetes service with ha
Kubernetes Networking 101
Deep dive in container service discovery
[20200720]cloud native develoment - Nelson Lin
Kubernetes - State of the Union (Q1-2016)
DockerCon EU 2015: The Glue is the Hard Part: Making a Production-Ready PaaS
Overview of kubernetes network functions
Kubernetes on the Edge / 在邊緣的K8S
Docker Summit 2016 - Kubernetes: Sweets and Bitters
Lifecycle of a pod
Kubernetes - Starting with 1.2
Kubernetes meetup 101
Kubernetes Day 2017 - Build, Ship and Run Your APP, Production !!
How to integrate Kubernetes in OpenStack: You need to know these project
Kubernetes 架構與虛擬化之差異
Ad

Similar to How to Achieve Canary Deployment on Kubernetes (20)

PPTX
VMware and Container Orchestration
PDF
Immutable infrastructure:觀念與實作 (建議)
PDF
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
PPTX
Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...
PPTX
IM5- Introduction to DevOps tooools.pptx
PPTX
Learn you some Ansible for great good!
PPTX
Jenkins advance topic
PDF
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
PPTX
Docker - Demo on PHP Application deployment
DOCX
kishore_Nokia
PDF
Antons Kranga Building Agile Infrastructures
PDF
create auto scale jboss cluster with openshift
PDF
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
ODP
Jbossworld Presentation
PDF
DevNetCreate - ACI and Kubernetes Integration
PDF
Fabric8: Better Software Faster with Docker, Kubernetes, Jenkins
PPTX
Continous Integration.pptx
PDF
Kubernetes for Java developers
PDF
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
PPTX
Continuous Integration for BSP
VMware and Container Orchestration
Immutable infrastructure:觀念與實作 (建議)
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...
IM5- Introduction to DevOps tooools.pptx
Learn you some Ansible for great good!
Jenkins advance topic
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
Docker - Demo on PHP Application deployment
kishore_Nokia
Antons Kranga Building Agile Infrastructures
create auto scale jboss cluster with openshift
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
Jbossworld Presentation
DevNetCreate - ACI and Kubernetes Integration
Fabric8: Better Software Faster with Docker, Kubernetes, Jenkins
Continous Integration.pptx
Kubernetes for Java developers
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
Continuous Integration for BSP
Ad

Recently uploaded (20)

PDF
composite construction of structures.pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Construction Project Organization Group 2.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Welding lecture in detail for understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPT
Drone Technology Electronics components_1
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
composite construction of structures.pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
OOP with Java - Java Introduction (Basics)
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Construction Project Organization Group 2.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Welding lecture in detail for understanding
Operating System & Kernel Study Guide-1 - converted.pdf
Geodesy 1.pptx...............................................
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Lesson 3_Tessellation.pptx finite Mathematics
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Lecture Notes Electrical Wiring System Components
bas. eng. economics group 4 presentation 1.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Drone Technology Electronics components_1
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...

How to Achieve Canary Deployment on Kubernetes

Editor's Notes

  • #4: 參加者的背景 infra / development 有那些參加者的公司是用 kubernetes 跑 production 在座的各位會參與到上版作業嗎? 上版流程有用到 canary 的方式嗎?
  • #8: https://blog.marsen.me/2018/01/07/2018/six_strategies_for_application_deployment/
  • #11: https://blog.marsen.me/2018/01/07/2018/six_strategies_for_application_deployment/
  • #21: Deployment 對應的 ReplicaSet 同時間只會有一份在運行
  • #22: kubernetes canary deployments
  • #32: What is Helm?