Skip to content

Blue-Green Deployment

In one line

Blue-green deployment maintains two identical environments (blue and green) and switches traffic from old to new in one step.

In simple words

Blue-green deployment is a release strategy that reduces downtime and risk. You maintain two identical production environments: blue (the current version) and green (the new version).

  1. Deploy the new version to the green environment (while blue is still serving traffic).
  2. Test the green environment to make sure it works.
  3. Switch the router/load balancer to send all traffic to green instead of blue.
  4. If something goes wrong, switch back to blue instantly (rollback).
  5. Once green is confirmed stable, blue becomes the old version for the next release.

The advantage is instant rollback — you just switch the router back. The disadvantage is that you need double capacity (two full environments running). A related strategy is canary deployment, where you route a small percentage of traffic to the new version first to test it.

Example

bash
# 1. Deploy new version as 'green'
kubectl apply -f deployment-green.yaml

# 2. Test green environment
curl http://green-service/health

# 3. Switch traffic from blue to green
kubectl patch service my-app -p '{"spec":{"selector":{"version":"green"}}}'

# 4. If issues, switch back to blue instantly
kubectl patch service my-app -p '{"spec":{"selector":{"version":"blue"}}}'

Deploy green, test it, switch the Service selector to route traffic to green, and switch back to blue if needed.

How it works

  1. The current version runs in the blue environment.
  2. You deploy the new version to the green environment (no traffic yet).
  3. You test green to verify it works correctly.
  4. You switch the load balancer/router to send all traffic to green.
  5. If problems occur, switch back to blue instantly. Blue and green swap roles for the next release.

Common confusions

  • Confused with: Canary Deployment

    The difference: Blue-green switches all traffic at once (100% to new); canary gradually increases traffic to the new version (e.g., 5% → 25% → 100%), allowing earlier detection of issues.

Related terms

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary