Skip to main content

Chapter 3.7 - Deployment Strategies

Learning Objectives

By the end of this chapter, you will be able to:

  • Understand the different deployment strategies
  • Implement Rolling Updates
  • Use Blue/Green deployments
  • Set up Canary deployments

Types of Strategies

1. Rolling Update (Default)

Progressive update without interruption:

Configuration:

strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # Additional Pods allowed
maxUnavailable: 0 # Maximum unavailable Pods

2. Recreate

Deletes everything then recreates:

Configuration:

strategy:
type: Recreate

Blue/Green Deployment

Deploying two complete environments:

Advantages:

  • Instant rollback
  • Full testing before switch
  • No version mixing

Implementation:

  • Two separate Deployments
  • Service that points to one or the other
  • Switch via selector change

Canary Deployment

Progressive deployment to a small percentage:

Process:

  1. Deploy the new version to 10%
  2. Monitor metrics
  3. Gradually increase if OK
  4. Rollback if there is a problem

Implementation:

  • Two Deployments with different labels
  • Service with weighted selection
  • Or use Istio for advanced routing

Advanced Configuration

MaxSurge and MaxUnavailable

strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2 # Can create 2 additional Pods
maxUnavailable: 1 # 1 Pod can be unavailable

Example with 3 replicas:

  • During update: 4-5 Pods possible (3 + maxSurge)
  • Minimum available: 2 Pods (3 - maxUnavailable)

Summary

In this chapter, you learned:

Rolling Update: Progressive update (default)
Recreate: Deletion then recreation
Blue/Green: Two complete environments
Canary: Progressive deployment to a small percentage
Configuration: maxSurge and maxUnavailable to control the process


Next Steps

Now that you know the strategies:

Chapter 3.8: Health Checks
Lab 3.3: Deployments and Rolling Updates


Chapter created: December 2024