SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
info@container-solutions.com
container-solutions.com
Kubernetes
Deployment
Strategies
Etienne Tremel
etienne.tremel@container-solutions.com
@etiennetremel
20.03.2018
Day of Cloud, Oslo
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
What is what?
A
F
C D
E
B
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Kubernetes deployment: in brief
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Kubernetes deployment: complex routing
Ingress controllers:
- Nginx
- Traefik
- Istio
- GKE
- etc.
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Kubernetes deployment: configuration
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Readiness/Liveness probeapiVersion: v1
kind: Pod
metadata:
name: goproxy
labels:
app: goproxy
spec:
containers:
- name: goproxy
image: k8s.gcr.io/goproxy:0.1
ports:
- containerPort: 8080
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
Liveness
Any code greater than or equal to 200 and less
than 400 indicates success. Any other code
indicates failure.
livenessProbe:
httpGet:
path: /healthz
port: liveness-port
HTTP request:
Readiness
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
Shell command:
Exit code return 0: healthy
Exit code return 1: unhealthy
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Getting started
1. git clone -b gke
https://github.com/ContainerSolutions/k8s-deployment-strategies
2. Play around with the different strategies
■ Recreate
■ Ramped
■ Blue/Green
■ Canary
■ A/B Testing
■ Shadow
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
[...]
kind: Deployment
spec:
replicas: 3
strategy:
type: Recreate
[...]
$ kubectl apply -f ./manifest.yaml
Recreate
Version A is terminated then version B is rolled out
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Recreate
Version A is terminated then version B is rolled out
Pros:
- easy to setup
Cons:
- high impact on the user, expect downtime that depends on both shutdown and
boot duration of the application
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Ramped (aka incremental, rolling update)
Version B is slowly rolled out and replacing version A
[...]
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Ramped (aka incremental, rolling update)
Version B is slowly rolled out and replacing version A
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Blue/Green (aka Red/Black)
Version B is released alongside version A, then the traffic is switched to version B
[...]
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Blue/Green (aka Red/Black)
Version B is released alongside version A, then the traffic is switched to version B
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Canary
Version B is released to a subset of users, then proceed to a full rollout
[...]
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Canary
Version B is released to a subset of users, then proceed to a full rollout
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
A/B Testing
Version B is released to a subset of users under specific condition
[...]
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
A/B Testing
Version B is released to a subset of users under specific condition
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Shadow(aka mirrored)
Version B receives real-world traffic alongside version A and doesn’t impact the response.
[...]
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Shadow(aka mirrored)
Version B receives real-world traffic alongside version A and doesn’t impact the response.
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
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
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
Decision
diagram
container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel
info@container-solutions.com
container-solutions.com
Thanks!
Etienne Tremel
etienne.tremel@container-solutions.com
@etiennetremel
Hands on Kubernetes deployment strategies:
github.com/ContainerSolutions/k8s-deployment-strategies
Blog post about strategies:
container-solutions.com/kubernetes-deployment-strategies
thenewstack.io/deployment-strategies
Next

Contenu connexe

Dernier

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Dernier (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%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
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

En vedette

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Kubernetes Deployment Strategies Workshop - Day Of Cloud - 20.03.2018

  • 1. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel info@container-solutions.com container-solutions.com Kubernetes Deployment Strategies Etienne Tremel etienne.tremel@container-solutions.com @etiennetremel 20.03.2018 Day of Cloud, Oslo
  • 2. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel What is what? A F C D E B
  • 3. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Kubernetes deployment: in brief
  • 4. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Kubernetes deployment: complex routing Ingress controllers: - Nginx - Traefik - Istio - GKE - etc.
  • 5. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Kubernetes deployment: configuration
  • 6. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Readiness/Liveness probeapiVersion: v1 kind: Pod metadata: name: goproxy labels: app: goproxy spec: containers: - name: goproxy image: k8s.gcr.io/goproxy:0.1 ports: - containerPort: 8080 readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: tcpSocket: port: 8080 initialDelaySeconds: 15 periodSeconds: 20 Liveness Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure. livenessProbe: httpGet: path: /healthz port: liveness-port HTTP request: Readiness livenessProbe: exec: command: - cat - /tmp/healthy Shell command: Exit code return 0: healthy Exit code return 1: unhealthy
  • 7. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Getting started 1. git clone -b gke https://github.com/ContainerSolutions/k8s-deployment-strategies 2. Play around with the different strategies ■ Recreate ■ Ramped ■ Blue/Green ■ Canary ■ A/B Testing ■ Shadow
  • 8. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel [...] kind: Deployment spec: replicas: 3 strategy: type: Recreate [...] $ kubectl apply -f ./manifest.yaml Recreate Version A is terminated then version B is rolled out
  • 9. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Recreate Version A is terminated then version B is rolled out Pros: - easy to setup Cons: - high impact on the user, expect downtime that depends on both shutdown and boot duration of the application
  • 10. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Ramped (aka incremental, rolling update) Version B is slowly rolled out and replacing version A [...] 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
  • 11. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Ramped (aka incremental, rolling update) Version B is slowly rolled out and replacing version A 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
  • 12. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Blue/Green (aka Red/Black) Version B is released alongside version A, then the traffic is switched to version B [...] 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
  • 13. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Blue/Green (aka Red/Black) Version B is released alongside version A, then the traffic is switched to version B 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
  • 14. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Canary Version B is released to a subset of users, then proceed to a full rollout [...] 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
  • 15. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Canary Version B is released to a subset of users, then proceed to a full rollout 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
  • 16. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel A/B Testing Version B is released to a subset of users under specific condition [...] 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
  • 17. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel A/B Testing Version B is released to a subset of users under specific condition 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
  • 18. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Shadow(aka mirrored) Version B receives real-world traffic alongside version A and doesn’t impact the response. [...] 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
  • 19. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Shadow(aka mirrored) Version B receives real-world traffic alongside version A and doesn’t impact the response. 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
  • 20. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel 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
  • 21. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel Decision diagram
  • 22. container-solutions.com etienne.tremel@container-solutions.com Kubernetes Deployment Strategies @etiennetremel info@container-solutions.com container-solutions.com Thanks! Etienne Tremel etienne.tremel@container-solutions.com @etiennetremel Hands on Kubernetes deployment strategies: github.com/ContainerSolutions/k8s-deployment-strategies Blog post about strategies: container-solutions.com/kubernetes-deployment-strategies thenewstack.io/deployment-strategies Next