Deployment strategies
Source: Dev.to
Rolling Update
What it is
Kubernetes gradually replaces old Pods with new Pods, providing zero downtime when configured correctly.
How it works
- Some old Pods are terminated.
- New Pods are created step by step.
- Traffic is shared during the transition.
Key settings
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
Pros
- Zero downtime (default behavior).
- Simple and production‑ready.
Cons
- Old and new versions run together, which can complicate database/schema changes.
When to use
- Most web apps, APIs, and microservices.
Recreate
What it is
All old Pods are stopped, then new Pods are created.
Config
strategy:
type: Recreate
Pros
- Very simple.
- No version mixing.
Cons
- ❌ Downtime – users see a service interruption.
When to use
- Single‑instance apps.
- Development / test environments.
- Applications that cannot run multiple versions simultaneously.
Blue‑Green
What it is
Two environments are maintained:
- Blue – the current version.
- Green – the new version.
Traffic switches instantly from blue to green.
How to implement
- Deploy the new version to a separate set of Pods (green).
- Update the Service selector (or Ingress) to point to the green Pods.
Pros
- Instant rollback.
- No downtime.
- Very safe deployment.
Cons
- Requires double the resources while both environments exist.
- Typically manual or tool‑driven.
When to use
- High‑risk releases.
- Critical production systems.
Canary
What it is
The new version is released to a small percentage of users, then traffic is gradually increased.
How to implement
- Deploy fewer replicas for the canary version, or
- Use traffic splitting via Ingress or a Service Mesh.
Pros
- Very low risk; bugs are detected early.
Cons
- More complex setup.
- Requires monitoring and metrics.
When to use
- Large user bases.
- Performance‑sensitive applications.
A/B Testing
What it is
Different users receive different versions based on headers, cookies, or regions.
Pros
- Enables business experimentation and feature comparison.
Cons
- Complex setup.
- Not a pure “deployment” strategy.
When to use
- Feature testing.
- Product experiments.
Strategy Comparison
| Strategy | Downtime | Risk | Complexity | Production Use |
|---|---|---|---|---|
| Rolling Update | No | Medium | Low | ✅ Yes |
| Recreate | Yes | High | Very Low | ❌ Rare |
| Blue‑Green | No | Low | Medium | ✅ Yes |
| Canary | No | Very Low | High | ✅ Yes |
| A/B Testing | No | Very Low | Very High | ⚠️ Special |