MODULE 4/LESSON 6
☸️ Docker & Kubernetes

Rolling Updates & Canary Deployments

Rolling Updates, Canary Deployments, and Blue-Green Deployments in Kubernetes

12 min
Deploying a new version of your application shouldn't mean downtime for your users. Kubernetes supports advanced deployment strategies natively, allowing you to transition traffic from version 1 to version 2 seamlessly.

Key Concepts

Rolling Updates

The default K8s strategy. It incrementally replaces old pods with new ones. A new v2 Pod starts up, passes its Readiness Probe, begins taking traffic, and only then is an old v1 Pod terminated. This guarantees zero downtime.

Canary Deployments

Release a new version to a small percentage of users (e.g., 5%). You monitor error rates and logs. If everything looks healthy, you gradually ramp up to 100%. If it fails, you roll back affecting only 5% of users.

Blue-Green Deployments

You deploy a complete, identical copy of your production environment (Green). You test it thoroughly in isolation. Once verified, you flip a switch at the Load Balancer to route 100% of traffic from Blue to Green instantly.

Readiness Probes

Zero downtime is impossible without Readiness Probes. Kubernetes needs to know exactly when your app has finished booting and is ready to accept HTTP connections before sending it traffic.

Zero-Downtime Deployment Strategies

Kubernetes Rolling Update (Zero Downtime) Kubernetes Service (Load Balancer) Step 1: 100% v1 Traffic Pod v1 (Running) Pod v1 (Running) Pod v1 (Running) Step 2: Start new v2, Stop old v1 Pod v2 (Starting...) Pod v1 (Running) Pod v1 (Terminating) Step 3: 100% v2 Traffic Pod v2 (Running) Pod v2 (Running) Pod v2 (Running)

Comparing the Strategies

StrategyProsConsUse Case
RollingRequires no extra resources (servers)Hard to rollback quickly, mixed versions run simultaneouslyStandard stateless microservices
Blue-GreenInstant rollback, zero version mixingRequires 2x the infrastructure costs during deploymentHigh-risk, database-heavy legacy apps
CanaryTests in real production safely, lowest riskComplex to configure (needs Service Mesh like Istio or advanced Ingress)Huge userbases where any bug is expensive
💡
Senior Architect Insight: One hidden danger of Rolling Updates: Backward Compatibility. Because v1 and v2 Pods are running simultaneously for a brief period during the deployment, they are both reading/writing to the same Database. Therefore, any database schema changes must be fully backward compatible with the older version of the code.