2 min read

Blue/Green Deployment Strategy on Kubernetes

Visual comparison of deployment strategies for safety
Street photograph by Stalin Pereira
Photo by Stalin Pereira

Stop Praying During Deploys

Why release day doesn't have to be a gamble.

The 'Open Heart Surgery' Problem

  • The Scenario — Imagine trying to replace a heart valve while the patient is still running a marathon.
  • The Risk — One slip-up, and the whole system (patient) crashes. There is no 'undo' button.
  • The Reality — This is what a 'Big Bang' deployment feels like. High stress, high risk.

Don't Fix It In Place

  • The Shift — Smart teams don't fix the live system. They build a new one next to it.
  • The Goal — Decouple the 'Deployment' (installing code) from the 'Release' (users seeing it).

Strategy 1: Blue/Green

The 'Parallel Universe' Approach

  • Setup — You run two identical environments. 'Blue' is live. 'Green' is idle.
  • The Deploy — You install the new version on Green. Real users are still on Blue.
  • The Switch — Once Green is tested, you flip the router. 100% of traffic moves instantly.

Blue/Green: The Good & Bad

  • Pro: Instant Rollback — Something broke? Flip the switch back to Blue. Downtime is milliseconds.
  • Con: Double Cost — You are paying for two full environments, even though one is idle.
  • Use Case — Best for critical apps where downtime is unacceptable and budget allows.

Strategy 2: Canary

The 'Testing the Waters' Approach

  • The Concept — Like a canary in a coal mine. Send the new version to a tiny group first.
  • The Process — Route 99% of users to Old (Stable). Route 1% to New (Risky).
  • The Ramp Up — If no errors occur, increase traffic: 10%... 50%... 100%.

Canary: The Good & Bad

  • Pro: Zero Blast Radius — If the new code crashes, it only affects 1% of users. The rest are safe.
  • Pro: Real World Test — You test with real production traffic, not just QA scripts.
  • Con: Complexity — Requires smart routing and automated observability to work well.

Visual Comparison

  • Blue/Green — All-or-nothing switch. Fast, but binary.
  • Canary — Gradual drip. Slow, but safer for obscure bugs.
  • Rolling Update — The middle ground. Replace instances one by one (Standard K8s).

Under the Hood: How it Works

  • Load Balancer — The traffic cop. It decides which server (Blue or Green) gets the request.
  • DNS Switching — Changing the address the domain points to (slower, cached).
  • Service Mesh — Advanced: Can route traffic based on user ID or location (for Canaries).

When to Use Which?

  • Choose Blue/Green — If you have database schema changes that are backward compatible.
  • Choose Canary — If you are worried about performance issues or UI bugs.
  • Avoid Both — If you are a tiny startup. A simple maintenance window might be enough.

The Business Impact

Why stakeholders should care about deployment strategy.

  • Reputation — Users don't forgive downtime. Stability builds trust.
  • Developer Velocity — Safe deploys mean engineers ship faster without fear of breaking things.
  • Revenue — Availability is money. 99.9% uptime is the baseline.

Summary: Sleep Better

Safety is an architectural choice.

Invest in your pipeline, and weekends become yours again.

Which strategy does your team trust the most?