SlideShare a Scribd company logo
1 of 61
Download to read offline
Deployment Strategies on
Kubernetes
By Etienne Tremel
Software engineer at Container Solutions
@etiennetremel
February 13th, 2017
Agenda
• Kubernetes in brief
• Look at 6 different strategies
• Recreate
• Ramped
• Blue/Green
• Canary
• A/B Testing
• Shadow
• Sum-up
• Next
2
Kubernetes in brief
Deployments, replica-sets, pods and services
3
Kubernetes in brief
Advanced routing using Ingress
4
Ingress controllers:
- Nginx
- HA Proxy
- Traefik
- Istio
- Linkerd
- GKE
- etc.
Kubernetes in brief
Configuration
5
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
Deployment configuration:
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 9376
Service configuration:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /foo
backend:
serviceName: my-service
servicePort: 80
- path: /bar
backend:
serviceName: my-other-service
servicePort: 80
Ingress configuration:
Deployment
ReplicaSet
Pod
Deployment strategies
6
• Recreate native
• Ramped native
• Blue/Green extra step needed
• Canary extra step needed
• A/B Testing require additional component
• Shadow require additional component
Get your hands on: https://github.com/ContainerSolutions/k8s-deployment-strategies
7
Recreate
Recreate
8
In this case [LB] is a Kubernetes Service
Recreate
9
In this case [LB] is a Kubernetes Service
Recreate
10
In this case [LB] is a Kubernetes Service
Recreate
11
In this case [LB] is a Kubernetes Service
Recreate
12
[...]
kind: Deployment
spec:
replicas: 3
strategy:
type: Recreate
[...]
$ kubectl apply -f ./manifest.yaml
Recreate
Pattern of the traffic during a release
13
Service unavailable
Recreate
Pros:
• easy to setup
Cons:
• high impact on the user, expect downtime that depends on both shutdown and boot duration
of the application
14
15
Ramped
aka incremental, rolling update
Ramped - aka Incremental, Rolling
16
In this case [LB] is a Kubernetes Service
Ramped - aka Incremental, Rolling
17
In this case [LB] is a Kubernetes Service
Ramped - aka Incremental, Rolling
18
In this case [LB] is a Kubernetes Service
Ramped - aka Incremental, Rolling
19
In this case [LB] is a Kubernetes Service
Ramped - aka Incremental, Rolling
20
In this case [LB] is a Kubernetes Service
Ramped - aka Incremental, Rolling
21
[...]
kind: Deployment
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2 # how many pods we can add at a time
maxUnavailable: 0 # maxUnavailable define how many pods can be
# unavailable during the rolling update
[...]
$ kubectl apply -f ./manifest.yaml
Ramped - aka Incremental, Rolling
Pattern of the traffic during a release
22
Ramped - aka Incremental, Rolling
Pros:
• easy to use
• version is slowly released across instances
• convenient for stateful applications that can handle ongoing rebalancing of the data
Cons:
• rollout/rollback can take time
• no control over traffic
23
24
Blue/Green
aka red/black
Blue/Green - aka Red/Black
25
Blue/Green - aka Red/Black
26
Blue/Green - aka Red/Black
27
Blue/Green - aka Red/Black
28
Blue/Green - aka Red/Black
Single service deployment
29
[...]
kind: Service
spec:
# Note here that we match both the app and the version.
# When switching traffic, update the label “version” with
# the appropriate value, ie: v2.0.0
selector:
app: my-app
version: v1.0.0
[...]
$ kubectl apply -f ./manifest-v2.yaml
$ kubectl patch service my-app -p 
'{"spec":{"selector":{"version":"v2.0.0"}}}'
$ kubectl delete -f ./manifest-v1.yaml
Blue/Green - aka Red/Black
To rollout multiple services at once, use Ingress
30
[...]
kind: Ingress
spec:
rules:
- host: login.domain.com
http:
paths:
- backend:
serviceName: login-v2
servicePort: 80
- host: cart.domain.com
http:
paths:
- backend:
serviceName: cart-v2
servicePort: 80
[...]
[...]
kind: Service
metadata:
name: login-v2
spec:
selector:
app: login
version: v2.0.0
[...]
[...]
kind: Service
metadata:
name: cart-v2
spec:
selector:
app: cart
version: v2.0.0
[...]
$ kubectl apply -f ./manifest-v2.yaml
$ kubectl apply -f ./ingress.yaml
$ kubectl delete -f ./manifest-v1.yaml
Blue/Green - aka Red/Black
Pattern of the traffic during a release
31
Blue/Green - aka Red/Black
Pros:
• instant rollout/rollback
• good fit for front-end that load versioned assets from the same server
• dirty way to fix application dependency hell
Cons:
• expensive as it requires double the resources
• proper test of the entire platform should be done before releasing to production
32
33
Canary
Canary
34
Canary
35
Canary
36
Canary
37
Canary
38
[...]
kind: Deployment
metadata:
name: my-app-v1
spec:
replicas: 9
template:
labels:
app: my-app
version: v1.0.0
[...]
[...]
kind: Service
metadata:
name: my-app
spec:
selector:
app: my-app
[...]
[...]
kind: Deployment
metadata:
name: my-app-v2
spec:
replicas: 1
template:
labels:
app: my-app
version: v2.0.0
[...]
$ kubectl apply -f ./manifest-v2.yaml
$ kubectl scale deploy/my-app-v2 --replicas=10
$ kubectl delete -f ./manifest-v1.yaml
Canary
Example of shifting traffic based on weight (percentage) using Istio
39
[...]
kind: RouteRule
metadata:
name: my-app
spec:
destination:
name: my-app
route:
- labels:
version: v1.0.0
weight: 90 # 90% traffic
- labels:
version: v2.0.0
weight: 10 # 10% traffic
[...]
$ kubectl apply -f ./manifest-v2.yaml
$ kubectl apply -f ./routerule.yaml
Canary
Pattern of the traffic during a release
40
Canary
Pros:
• version released for a subset of users
• convenient for error rate and performance monitoring
• fast rollback
Cons:
• slow rollout
• sticky sessions might be required
• precise traffic shifting would require additional tool like Istio or Linkerd
41
42
A/B Testing
A/B Testing
43
A/B Testing
44
A/B Testing
45
A/B Testing
46
Possible conditions:
- Geolocalisation
- Language
- Cookie
- User Agent (device, OS, etc.)
- Custom Header
- Query parameters
A/B Testing
Example of shifting traffic based on request Headers using Istio
47
[...]
kind: RouteRule
metadata:
name: my-app-v1
spec:
destination:
name: my-app
route:
- labels:
version: v1.0.0
match:
request:
headers:
x-api-version:
exact: "v1.0.0"
[...]
[...]
kind: RouteRule
metadata:
name: my-app-v2
spec:
destination:
name: my-app
route:
- labels:
version: v2.0.0
match:
request:
headers:
x-api-version:
exact: "v2.0.0"
[...]
$ kubectl apply -f ./manifest-v2.yaml
$ kubectl apply -f ./routerule.yaml
A/B Testing
Pattern of the traffic during a release
48
A/B Testing
Pros:
• several versions run in parallel
• full control over the traffic distribution
• great tool that can be used for business purpose to improve conversion
Cons:
• requires intelligent load balancer (Istio, Linkerd, etc.)
• hard to troubleshoot errors for a given session, distributed tracing becomes mandatory
49
50
Shadow
aka Mirrored, Dark
Shadow - aka Mirrored, Dark
51
Shadow - aka Mirrored, Dark
52
Shadow - aka Mirrored, Dark
53
Shadow - aka Mirrored, Dark
54
Shadow - aka Mirrored, Dark
Example of mirroring traffic using Istio
55
[...]
kind: RouteRule
spec:
destination:
name: my-app
route:
- labels:
version: v1.0.0
weight: 100
- labels:
version: v2.0.0
weight: 0
mirror:
name: my-app-v2
labels:
version: v2.0.0
[...]
$ kubectl apply -f ./manifest-v2.yaml
$ kubectl apply -f ./routerule.yaml
Shadow - aka Mirrored, Dark
Pattern of the traffic during a release
56
Shadow - aka Mirrored, Dark
Pros:
• performance testing of the application with production traffic
• no impact on the user
• no rollout until the stability and performance of the application meet the requirements
Cons:
• complex to setup
• expensive as it requires double the resources
• not a true user test and can be misleading
• requires mocking/stubbing service for certain cases
57
Sum-up
• recreate if downtime is not a problem
• recreate and ramped doesn’t require any extra step (kubectl apply is enough)
• ramped and blue/green deployment are usually a good fit and easy to use
• blue/green is a good fit for front-end that load versioned assets from the same server
• blue/green and shadow can be expensive
• canary and a/b testing should be used if little confidence on the quality of the release
• canary, a/b testing and shadow might require additional cluster component
58
Sum-up
59
Next
Hands on Kubernetes deployment strategies:
https://github.com/ContainerSolutions/k8s-deployment-strategies
Blog post about strategies:
https://container-solutions.com/kubernetes-deployment-strategies
https://thenewstack.io/deployment-strategies
60
Thank You
61

More Related Content

What's hot

Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes VMware Tanzu
 
Open shift 4 infra deep dive
Open shift 4    infra deep diveOpen shift 4    infra deep dive
Open shift 4 infra deep diveWinton Winton
 
VMware Tanzu Introduction- June 11, 2020
VMware Tanzu Introduction- June 11, 2020VMware Tanzu Introduction- June 11, 2020
VMware Tanzu Introduction- June 11, 2020VMware Tanzu
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull RequestKasper Nissen
 
Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...
Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...
Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...Edureka!
 
Quarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkQuarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkSVDevOps
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionStefan Schimanski
 
Rancher Rodeo
Rancher RodeoRancher Rodeo
Rancher RodeoSUSE
 
VMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes ConnectVMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes ConnectVMware Tanzu
 
Getting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeGetting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeWinWire Technologies Inc
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introductionSparkbit
 
Kubernetes
KubernetesKubernetes
KubernetesHenry He
 
Everything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in KubernetesEverything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in KubernetesThe {code} Team
 
GitOps with ArgoCD
GitOps with ArgoCDGitOps with ArgoCD
GitOps with ArgoCDCloudOps2005
 

What's hot (20)

Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Open shift 4 infra deep dive
Open shift 4    infra deep diveOpen shift 4    infra deep dive
Open shift 4 infra deep dive
 
VMware Tanzu Introduction- June 11, 2020
VMware Tanzu Introduction- June 11, 2020VMware Tanzu Introduction- June 11, 2020
VMware Tanzu Introduction- June 11, 2020
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull Request
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...
Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...
Kubernetes Deployment Tutorial | Kubernetes Tutorial For Beginners | Kubernet...
 
Quarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkQuarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java framework
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and Introduction
 
Kubernetes 101 Workshop
Kubernetes 101 WorkshopKubernetes 101 Workshop
Kubernetes 101 Workshop
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Rancher Rodeo
Rancher RodeoRancher Rodeo
Rancher Rodeo
 
VMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes ConnectVMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes Connect
 
Getting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeGetting Started with Infrastructure as Code
Getting Started with Infrastructure as Code
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introduction
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Cloud Native In-Depth
Cloud Native In-DepthCloud Native In-Depth
Cloud Native In-Depth
 
Everything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in KubernetesEverything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in Kubernetes
 
GitOps with ArgoCD
GitOps with ArgoCDGitOps with ArgoCD
GitOps with ArgoCD
 

Similar to Kubernetes deployment strategies - CNCF Webinar

Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10Vishnu Kannan
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthroughSangwon Lee
 
Zero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesZero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesWojciech Barczyński
 
DCEU 18: Docker Container Networking
DCEU 18: Docker Container NetworkingDCEU 18: Docker Container Networking
DCEU 18: Docker Container NetworkingDocker, Inc.
 
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless OverviewOpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless OverviewMaría Angélica Bracho
 
Istio Playground
Istio PlaygroundIstio Playground
Istio PlaygroundQAware GmbH
 
What's new in Kubernetes
What's new in KubernetesWhat's new in Kubernetes
What's new in KubernetesDaniel Smith
 
Cloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit KubernetesCloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit KubernetesQAware GmbH
 
Getting Started with MariaDB with Docker
Getting Started with MariaDB with DockerGetting Started with MariaDB with Docker
Getting Started with MariaDB with DockerMariaDB plc
 
How Honestbee Does CI/CD on Kubernetes - Vincent DeSmet
How Honestbee Does CI/CD on Kubernetes - Vincent DeSmetHow Honestbee Does CI/CD on Kubernetes - Vincent DeSmet
How Honestbee Does CI/CD on Kubernetes - Vincent DeSmetDevOpsDaysJKT
 
GitOps & the deployment branching models - DevOps D-day Marseille 2021
GitOps & the deployment branching models - DevOps D-day Marseille 2021GitOps & the deployment branching models - DevOps D-day Marseille 2021
GitOps & the deployment branching models - DevOps D-day Marseille 2021SoKube
 
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17Mario-Leander Reimer
 
A hitchhiker‘s guide to the cloud native stack
A hitchhiker‘s guide to the cloud native stackA hitchhiker‘s guide to the cloud native stack
A hitchhiker‘s guide to the cloud native stackQAware GmbH
 
Docker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platformsDocker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platformsFederico Michele Facca
 
Successful K8S Platforms in Airgapped Environments
Successful K8S Platforms in Airgapped EnvironmentsSuccessful K8S Platforms in Airgapped Environments
Successful K8S Platforms in Airgapped EnvironmentsKubernetesCommunityD
 
New Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud ApplicationsNew Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud ApplicationsMichael Hofmann
 
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTOClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTOAltinity Ltd
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...Amazon Web Services
 
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Daniel Bryant
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetesLiran Cohen
 

Similar to Kubernetes deployment strategies - CNCF Webinar (20)

Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthrough
 
Zero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesZero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with Kubernetes
 
DCEU 18: Docker Container Networking
DCEU 18: Docker Container NetworkingDCEU 18: Docker Container Networking
DCEU 18: Docker Container Networking
 
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless OverviewOpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
 
Istio Playground
Istio PlaygroundIstio Playground
Istio Playground
 
What's new in Kubernetes
What's new in KubernetesWhat's new in Kubernetes
What's new in Kubernetes
 
Cloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit KubernetesCloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit Kubernetes
 
Getting Started with MariaDB with Docker
Getting Started with MariaDB with DockerGetting Started with MariaDB with Docker
Getting Started with MariaDB with Docker
 
How Honestbee Does CI/CD on Kubernetes - Vincent DeSmet
How Honestbee Does CI/CD on Kubernetes - Vincent DeSmetHow Honestbee Does CI/CD on Kubernetes - Vincent DeSmet
How Honestbee Does CI/CD on Kubernetes - Vincent DeSmet
 
GitOps & the deployment branching models - DevOps D-day Marseille 2021
GitOps & the deployment branching models - DevOps D-day Marseille 2021GitOps & the deployment branching models - DevOps D-day Marseille 2021
GitOps & the deployment branching models - DevOps D-day Marseille 2021
 
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
 
A hitchhiker‘s guide to the cloud native stack
A hitchhiker‘s guide to the cloud native stackA hitchhiker‘s guide to the cloud native stack
A hitchhiker‘s guide to the cloud native stack
 
Docker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platformsDocker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platforms
 
Successful K8S Platforms in Airgapped Environments
Successful K8S Platforms in Airgapped EnvironmentsSuccessful K8S Platforms in Airgapped Environments
Successful K8S Platforms in Airgapped Environments
 
New Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud ApplicationsNew Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud Applications
 
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTOClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
 
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyAnusha Are
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Kubernetes deployment strategies - CNCF Webinar

  • 1. Deployment Strategies on Kubernetes By Etienne Tremel Software engineer at Container Solutions @etiennetremel February 13th, 2017
  • 2. Agenda • Kubernetes in brief • Look at 6 different strategies • Recreate • Ramped • Blue/Green • Canary • A/B Testing • Shadow • Sum-up • Next 2
  • 3. Kubernetes in brief Deployments, replica-sets, pods and services 3
  • 4. Kubernetes in brief Advanced routing using Ingress 4 Ingress controllers: - Nginx - HA Proxy - Traefik - Istio - Linkerd - GKE - etc.
  • 5. Kubernetes in brief Configuration 5 apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 Deployment configuration: kind: Service apiVersion: v1 metadata: name: my-service spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 9376 Service configuration: apiVersion: extensions/v1beta1 kind: Ingress metadata: name: my-ingress annotations: kubernetes.io/ingress.class: nginx spec: rules: - host: foo.bar.com http: paths: - path: /foo backend: serviceName: my-service servicePort: 80 - path: /bar backend: serviceName: my-other-service servicePort: 80 Ingress configuration: Deployment ReplicaSet Pod
  • 6. Deployment strategies 6 • Recreate native • Ramped native • Blue/Green extra step needed • Canary extra step needed • A/B Testing require additional component • Shadow require additional component Get your hands on: https://github.com/ContainerSolutions/k8s-deployment-strategies
  • 8. Recreate 8 In this case [LB] is a Kubernetes Service
  • 9. Recreate 9 In this case [LB] is a Kubernetes Service
  • 10. Recreate 10 In this case [LB] is a Kubernetes Service
  • 11. Recreate 11 In this case [LB] is a Kubernetes Service
  • 12. Recreate 12 [...] kind: Deployment spec: replicas: 3 strategy: type: Recreate [...] $ kubectl apply -f ./manifest.yaml
  • 13. Recreate Pattern of the traffic during a release 13 Service unavailable
  • 14. Recreate Pros: • easy to setup Cons: • high impact on the user, expect downtime that depends on both shutdown and boot duration of the application 14
  • 16. Ramped - aka Incremental, Rolling 16 In this case [LB] is a Kubernetes Service
  • 17. Ramped - aka Incremental, Rolling 17 In this case [LB] is a Kubernetes Service
  • 18. Ramped - aka Incremental, Rolling 18 In this case [LB] is a Kubernetes Service
  • 19. Ramped - aka Incremental, Rolling 19 In this case [LB] is a Kubernetes Service
  • 20. Ramped - aka Incremental, Rolling 20 In this case [LB] is a Kubernetes Service
  • 21. Ramped - aka Incremental, Rolling 21 [...] kind: Deployment spec: replicas: 3 strategy: type: RollingUpdate rollingUpdate: maxSurge: 2 # how many pods we can add at a time maxUnavailable: 0 # maxUnavailable define how many pods can be # unavailable during the rolling update [...] $ kubectl apply -f ./manifest.yaml
  • 22. Ramped - aka Incremental, Rolling Pattern of the traffic during a release 22
  • 23. Ramped - aka Incremental, Rolling Pros: • easy to use • version is slowly released across instances • convenient for stateful applications that can handle ongoing rebalancing of the data Cons: • rollout/rollback can take time • no control over traffic 23
  • 25. Blue/Green - aka Red/Black 25
  • 26. Blue/Green - aka Red/Black 26
  • 27. Blue/Green - aka Red/Black 27
  • 28. Blue/Green - aka Red/Black 28
  • 29. Blue/Green - aka Red/Black Single service deployment 29 [...] kind: Service spec: # Note here that we match both the app and the version. # When switching traffic, update the label “version” with # the appropriate value, ie: v2.0.0 selector: app: my-app version: v1.0.0 [...] $ kubectl apply -f ./manifest-v2.yaml $ kubectl patch service my-app -p '{"spec":{"selector":{"version":"v2.0.0"}}}' $ kubectl delete -f ./manifest-v1.yaml
  • 30. Blue/Green - aka Red/Black To rollout multiple services at once, use Ingress 30 [...] kind: Ingress spec: rules: - host: login.domain.com http: paths: - backend: serviceName: login-v2 servicePort: 80 - host: cart.domain.com http: paths: - backend: serviceName: cart-v2 servicePort: 80 [...] [...] kind: Service metadata: name: login-v2 spec: selector: app: login version: v2.0.0 [...] [...] kind: Service metadata: name: cart-v2 spec: selector: app: cart version: v2.0.0 [...] $ kubectl apply -f ./manifest-v2.yaml $ kubectl apply -f ./ingress.yaml $ kubectl delete -f ./manifest-v1.yaml
  • 31. Blue/Green - aka Red/Black Pattern of the traffic during a release 31
  • 32. Blue/Green - aka Red/Black Pros: • instant rollout/rollback • good fit for front-end that load versioned assets from the same server • dirty way to fix application dependency hell Cons: • expensive as it requires double the resources • proper test of the entire platform should be done before releasing to production 32
  • 38. Canary 38 [...] kind: Deployment metadata: name: my-app-v1 spec: replicas: 9 template: labels: app: my-app version: v1.0.0 [...] [...] kind: Service metadata: name: my-app spec: selector: app: my-app [...] [...] kind: Deployment metadata: name: my-app-v2 spec: replicas: 1 template: labels: app: my-app version: v2.0.0 [...] $ kubectl apply -f ./manifest-v2.yaml $ kubectl scale deploy/my-app-v2 --replicas=10 $ kubectl delete -f ./manifest-v1.yaml
  • 39. Canary Example of shifting traffic based on weight (percentage) using Istio 39 [...] kind: RouteRule metadata: name: my-app spec: destination: name: my-app route: - labels: version: v1.0.0 weight: 90 # 90% traffic - labels: version: v2.0.0 weight: 10 # 10% traffic [...] $ kubectl apply -f ./manifest-v2.yaml $ kubectl apply -f ./routerule.yaml
  • 40. Canary Pattern of the traffic during a release 40
  • 41. Canary Pros: • version released for a subset of users • convenient for error rate and performance monitoring • fast rollback Cons: • slow rollout • sticky sessions might be required • precise traffic shifting would require additional tool like Istio or Linkerd 41
  • 46. A/B Testing 46 Possible conditions: - Geolocalisation - Language - Cookie - User Agent (device, OS, etc.) - Custom Header - Query parameters
  • 47. A/B Testing Example of shifting traffic based on request Headers using Istio 47 [...] kind: RouteRule metadata: name: my-app-v1 spec: destination: name: my-app route: - labels: version: v1.0.0 match: request: headers: x-api-version: exact: "v1.0.0" [...] [...] kind: RouteRule metadata: name: my-app-v2 spec: destination: name: my-app route: - labels: version: v2.0.0 match: request: headers: x-api-version: exact: "v2.0.0" [...] $ kubectl apply -f ./manifest-v2.yaml $ kubectl apply -f ./routerule.yaml
  • 48. A/B Testing Pattern of the traffic during a release 48
  • 49. A/B Testing Pros: • several versions run in parallel • full control over the traffic distribution • great tool that can be used for business purpose to improve conversion Cons: • requires intelligent load balancer (Istio, Linkerd, etc.) • hard to troubleshoot errors for a given session, distributed tracing becomes mandatory 49
  • 51. Shadow - aka Mirrored, Dark 51
  • 52. Shadow - aka Mirrored, Dark 52
  • 53. Shadow - aka Mirrored, Dark 53
  • 54. Shadow - aka Mirrored, Dark 54
  • 55. Shadow - aka Mirrored, Dark Example of mirroring traffic using Istio 55 [...] kind: RouteRule spec: destination: name: my-app route: - labels: version: v1.0.0 weight: 100 - labels: version: v2.0.0 weight: 0 mirror: name: my-app-v2 labels: version: v2.0.0 [...] $ kubectl apply -f ./manifest-v2.yaml $ kubectl apply -f ./routerule.yaml
  • 56. Shadow - aka Mirrored, Dark Pattern of the traffic during a release 56
  • 57. Shadow - aka Mirrored, Dark Pros: • performance testing of the application with production traffic • no impact on the user • no rollout until the stability and performance of the application meet the requirements Cons: • complex to setup • expensive as it requires double the resources • not a true user test and can be misleading • requires mocking/stubbing service for certain cases 57
  • 58. Sum-up • recreate if downtime is not a problem • recreate and ramped doesn’t require any extra step (kubectl apply is enough) • ramped and blue/green deployment are usually a good fit and easy to use • blue/green is a good fit for front-end that load versioned assets from the same server • blue/green and shadow can be expensive • canary and a/b testing should be used if little confidence on the quality of the release • canary, a/b testing and shadow might require additional cluster component 58
  • 60. Next Hands on Kubernetes deployment strategies: https://github.com/ContainerSolutions/k8s-deployment-strategies Blog post about strategies: https://container-solutions.com/kubernetes-deployment-strategies https://thenewstack.io/deployment-strategies 60