Sub topic 11
Choosing a strategy: a comparison and decision guide
This chapter assumes you know how rolling, blue-green, and canary deployments work, and that you have used Kubernetes Deployments and Services. It does not repeat the mechanics. It shows how to choose between the strategies for a given service.
The four questions that drive the choice
No strategy is best everywhere. Each one trades risk, cost, speed, and complexity. Four questions narrow the choice quickly.
- How bad is a bad release? Think of money lost, users harmed, and the cost of a bad hour.
- How much spare capacity can you pay for?
- How fast must you be able to undo a release?
- Can the old and new versions run at the same time?
The last question comes first in practice. If the new version needs a database change that the old version cannot tolerate, no strategy that runs both versions together is safe until you change the schema in compatible steps.
Comparison
| Property | Rolling | Blue-green | Canary |
|---|---|---|---|
| Extra capacity | Small (the surge, for example `maxSurge: 1`) | Full second environment | Small (a few canary pods) |
| Users exposed to a bad version | Grows as the rollout proceeds | None before cutover, then all at once | A small share, by design |
| Rollback speed | Minutes (a new rollout in reverse) | Seconds (switch the selector back) | Seconds (set the weight to 0) |
| Both versions live together | Yes, during the rollout | Briefly, if you test green first | Yes, for the whole canary period |
| Needs traffic-routing tooling | No | A Service or load balancer switch | Weighted routing, such as an Ingress |
| Needs good metrics | Basic health checks | Smoke tests before cutover | Yes, to judge the canary |
| Operational complexity | Low | Medium | High |
Two cells need care. Blue-green exposes no one before the switch, but after it every user is on the new version at once. A bug that only shows under real traffic hits everyone. The canary limits that exposure, but only if you watch the right metrics and have a rule for promoting or aborting.
Decision guide
Start with the simplest strategy that fits your risk, and move up only when you have a reason.
In words:
- Choose rolling for most stateless services with low to moderate risk. It needs no extra tooling beyond readiness probes, and it is the Kubernetes default.
- Choose blue-green when you need an instant, whole-environment rollback, or when you must test the full new stack before any user sees it. You pay for two environments while both exist.
- Choose canary when a bad release is expensive and you have the metrics to judge it. It finds problems that only appear under real traffic, with the least damage.
Worked example
Consider three services.
- An internal admin tool with 20 users. A rolling update with
maxUnavailable: 0and a readiness probe is enough. A bad release is annoying, not costly. - A payments API with strict correctness needs. Use a canary at 5 to 10% of traffic. Watch error rate and latency, and compare them with the stable version before you promote.
- A monolith that changes its configuration format at startup. Use blue-green. You can start the green environment, run smoke tests, and switch the selector. If anything goes wrong, you switch it back.
A common combination is a rolling update inside each environment, with a blue-green or canary layer on top.
Common mistakes
- Choosing canary without metrics. A canary no one measures is a slow, partial release with no decision rule.
- Treating rollback as free. Switching traffic back does not undo a database migration that already ran.
- Choosing blue-green for a stateful service without planning for data. Both environments usually share one database, so the schema must work for both.
- Using a strategy more complex than the risk needs. Complexity is also a risk.
Exercise
A team runs a checkout service. Each release changes a database column, and the new code cannot read the old column layout. They want to use a canary. What must they do first, and why?
Show answer
They must make the schema change backward compatible, for example by adding the new column first and keeping the old one until the old version is gone. A canary runs old and new versions together against the same database, so both must work with the schema at every step.
Exercise
You run a stateless internal service on Kubernetes with no weighted routing and no release metrics. A bad release has low cost. Which strategy fits, and which settings keep it safe?
Show answer
A rolling update fits. Use a readiness probe so new pods get traffic only when ready, and set maxUnavailable: 0 with a maxSurge of 1 so capacity never drops during the rollout.