What you'll learn: By the end of this lesson you will be able to explain how a rolling update, a blue-green deployment and a canary release each move traffic to a new version, read the Kubernetes rolling-update settings and work out how many pods may exist or be unavailable, choose a strategy for a given service, say what a rollback does and does not undo, and explain why the database schema decides whether any of them is safe.
A bakery changes its bread recipe. It can swap one oven at a time while the others keep baking (rolling). It can build a second shop next door, taste everything there, then move the sign over (blue-green). Or it can hand the new loaf to a few regulars first and read their faces before baking it for everyone (canary). All three are about the same question: how many customers are exposed to the change, and how fast can you take it back?
This lesson compares the three for a back-end service. The build pipeline is the topic of the CI/CD pipelines lesson and the objects that run it are in the Kubernetes core objects lesson, both in the same module. Switching a feature on for some users, independent of the deployment, is the topic of feature flags.
Verified on 2026-12-01 against the Kubernetes documentation (Deployments, Services, probes), the Argo Rollouts documentation, Martin Fowler's pages on blue-green and canary releases, and the Google SRE Workbook chapter on canarying. No cluster was available: the YAML below is shown as not run. The two small Node scripts were run and their output is shown.
The core idea
A deployment strategy is a rule for how traffic moves from the old version to the new one, and therefore how much damage a bad release can do before you notice. The three strategies differ in what they trade: rolling replaces instances in place and costs almost nothing extra, blue-green pays for a second full environment to get an instant switch, and canary pays for observation time to limit how many users see a bad build.
Three illustrations run through the lesson:
- Minimal example: the Kubernetes default, a rolling update of 10 pods with the default surge and unavailability limits.
- Realistic example: ShopStream releases a new tax calculation in its checkout service.
- Failure example: the new pods never become ready and the rollout stalls.
A deployment puts a build on servers; a release exposes it to users. These strategies blur the two, and feature flags separate them again.
Rolling update: replace a few at a time
In a rolling update the platform starts pods of the new version and stops pods of the old one in small steps until none of the old remain. In Kubernetes this is the default for a Deployment: the documentation says RollingUpdate is the default value of .spec.strategy.type, and that the Deployment "gradually scale[s] down the old ReplicaSets and scale[s] up the new one".
Two settings bound each step:
maxSurge: the maximum number of pods that can be created over the desired number. A percentage is rounded up. Default 25%.maxUnavailable: the maximum number of pods that can be unavailable during the update. A percentage is rounded down. Default 25%.
The page adds that maxUnavailable cannot be 0 if maxSurge is 0, and the other way round. So at least one of them lets the controller move.
Minimal example (illustrative sizes). This script applies the documented rounding rules. It shows the bounds, not the controller's step-by-step behaviour.
function bounds(replicas, surgePct, unavailPct) {
const surge = Math.ceil((replicas * surgePct) / 100);
const unavailable = Math.floor((replicas * unavailPct) / 100);
if (surge === 0 && unavailable === 0) return { replicas, error: "both resolve to 0" };
return { replicas, surge, unavailable, maxPods: replicas + surge, minAvailable: replicas - unavailable };
}
for (const r of [3, 10, 40]) console.log(JSON.stringify(bounds(r, 25, 25)));
console.log(JSON.stringify(bounds(3, 0, 25)));
Run with Node v26.13.1, it printed:
{"replicas":3,"surge":1,"unavailable":0,"maxPods":4,"minAvailable":3}
{"replicas":10,"surge":3,"unavailable":2,"maxPods":13,"minAvailable":8}
{"replicas":40,"surge":10,"unavailable":10,"maxPods":50,"minAvailable":30}
{"replicas":3,"error":"both resolve to 0"}
Read the first line: with 3 replicas the defaults give a surge of 1 and an unavailability of 0, so the update brings up one new pod first and never dips below 3 available. The last line is a combination to avoid: both limits resolve to zero, which the documented rule forbids for the explicit values.
Figure 1. The shape of a rolling update. How to read this: new pods are added only as fast as they become ready, and old pods are removed only as fast as the limits allow. The last two lines are the failure case later in the lesson: a rollout that cannot make progress leaves the old pods in place.
Three properties follow from the mechanism:
- Two versions serve at once. For the length of the rollout, requests can reach either version. Every change must tolerate that: no endpoint may be removed that a client of the old version still calls, and no message format may be rewritten so the other version cannot read it.
- Readiness is the gate. The documentation says a pod "with containers reporting that they are not ready does not receive traffic through Kubernetes Services". A readiness probe that passes too early lets traffic reach a pod that cannot serve; the health checks lesson covers what a probe should test.
minReadySeconds(default 0) additionally requires a new pod to be ready without crashing for that long before it counts as available. - A rollout starts only when the pod template changes. The documentation says a rollout is triggered "if and only if"
.spec.templatechanges; scaling does not trigger one.
Rollback is a new rollout in reverse. Kubernetes keeps rollout history by default, kubectl rollout undo deployment/<name> returns to the previous revision, and --to-revision picks another. .spec.revisionHistoryLimit sets how many old ReplicaSets are kept (documented default 10); setting it to 0 removes the ability to roll back.
Recreate, the other built-in strategy, kills all existing pods before creating new ones: downtime, for a service that cannot run two versions at once.
Blue-green: two environments and a switch
In a blue-green deployment two production environments exist and one is live. The new version is deployed to the idle one, tested there, and traffic is then switched to it. Martin Fowler's page describes the two environments as "as identical as possible" and says rollback means to "switch the router back" to the old one.
Figure 2. Blue-green with a shared database. How to read this: the router sends all production traffic to blue. Green holds the new version and receives test traffic only. Promotion moves the router to green; blue stays warm for a fast rollback. Both stacks use one database, which is where the hard part is.
On Kubernetes the switch can be a Service selector: a Service targets "any Pod with the ... label" it selects, and the controller updates the Service's EndpointSlices as the matching pod set changes. Changing the label the Service selects moves the traffic. Argo Rollouts packages this: a blueGreen strategy has an activeService for production traffic and an optional previewService to test the new version. On promotion the controller points the active Service at the new ReplicaSet. autoPromotionEnabled defaults to true, so setting it false pauses before the switch; scaleDownDelaySeconds defaults to 30 and delays scaling down the old set so that routing tables can catch up.
# Shown as not run: fields as documented by Argo Rollouts.
strategy:
blueGreen:
activeService: checkout-active
previewService: checkout-preview
autoPromotionEnabled: false
What blue-green buys is that the switch is one decision and the old version stays running, so rollback is another single switch. What it costs:
- A second full environment while the new version is being verified.
- All-or-nothing exposure once promoted: after the switch every user is on the new version at once.
- Transactions that happened on green stay on green. Fowler notes that transactions processed by green while it was live can be missed on rollback.
- The database. Both colours read and write one schema, so the schema must work for both. Fowler's approach is to separate the schema change from the application upgrade.
Canary: expose a few, then decide
A canary release sends a small share of traffic to the new version and watches before widening. Fowler defines it as "slowly rolling out the change to a small subset of users" and notes the rollback is "simply to reroute users back to the old version". The Google SRE Workbook defines canarying as "a partial and time-limited deployment of a change in a service and its evaluation".
Figure 3. The canary loop. How to read this: the share only grows from a healthy evaluation. Any unhealthy evaluation ends in an abort that sends traffic back, not in a fix applied to the running canary.
Argo Rollouts expresses this as steps: setWeight sets the share of traffic to the canary and pause halts, with a duration or until promoted. Without a traffic router the controller approximates the weight with pod counts: with 10 replicas and a 10% weight it runs 1 canary pod and 9 stable ones, and finer control needs a traffic router (an ingress or service mesh, as the docs describe it). analysis can abort the rollout automatically when a check fails.
# Shown as not run: fields as documented by Argo Rollouts.
strategy:
canary:
steps:
- setWeight: 5
- pause: { duration: 10m }
- setWeight: 25
- pause: {}
A canary is only as good as its evaluation. The SRE Workbook gives the guidance a team can start from:
- Size and duration must be representative. The canary must be "sizeable and last long enough to be representative"; performance problems may only show under load.
- Few, attributable metrics. Keep roughly a dozen at most, such as error codes and latency, and compare the canary against a control, not before against after, because weekday and weekend traffic differ.
- Per-population metrics. Whole-service metrics can hide a canary's failures. Run one canary at a time.
The exposure arithmetic is simple: the Workbook's example is a 20% error rate on a 5% canary, which shows up as about 1% overall, against 20% for a full deployment.
Compatibility is the real constraint
Every strategy has a period when two versions run against the same data and call the same dependencies. That is why the rule is the same for all three: a release must be compatible with the version before it and the version after it. In practice:
- Schema changes use expand, migrate, contract. Add the new column or table first, deploy code that handles both, move data, then remove the old shape in a later release. The schema evolution lesson teaches this, including what each statement costs.
- Message and API contracts stay readable by both versions. Add fields, do not rename them in one step.
- Shared state is versioned or tolerant. A cache entry written by version 2 must not crash version 1.
A rollback that is possible for code is often not possible for data: once version 2 has written rows the old version does not understand, switching back is no longer safe. That is the difference between "can undo the deployment" and "can undo the change".
against the same data?"} Q1 -->|no| R1["Recreate, or fix compatibility first"] Q1 -->|yes| Q2{"Must a bad build reach
only a few users first?"} Q2 -->|yes| R2["Canary with metrics
and an abort rule"] Q2 -->|no| Q3{"Is an instant switch back
worth a second environment?"} Q3 -->|yes| R3["Blue-green"] Q3 -->|no| R4["Rolling update"]
Figure 4. A first-pass choice. How to read this: compatibility is asked first because it limits every other choice. Canary comes before blue-green because limiting exposure usually matters more than switching fast.
Trade-offs
| Rolling | Blue-green | Canary | |
|---|---|---|---|
| Extra capacity | Small (the surge) | A full second environment while verifying | Small, plus a traffic router for fine weights |
| Users exposed to a bad build | Grows as pods are replaced | All, after the switch | A chosen few |
| Rollback | A new rollout in reverse, takes time | One switch, old stack still running | Reroute to stable, fast |
| Needs | Readiness probes | Two environments, a switch | Metrics, a control group, an abort rule |
| Weakness | Two versions mix for the whole rollout | Cost, all-or-nothing | Needs enough traffic and a good evaluation |
Build it
There is no lab for this lesson. A real rollout needs a cluster, and none was available, so the YAML above is shown as not run and the only code that ran is the small rounding script.
In practice: ShopStream ships a new tax calculation
This is an educational scenario with illustrative numbers.
This is a realistic scenario, not a case history.
The situation
This is the realistic example. ShopStream's checkout service computes tax and totals. A new version changes how tax is rounded per line item. Checkout peaks at about 58 requests per second (the shared illustrative figure), so a 5% canary would see roughly 3 checkouts a second, about 1,700 in ten minutes (58 x 0.05 x 600).
Starting architecture
Figure 5. The checkout service today. How to read this: one Deployment of pods behind a Service, one database and a metrics feed. The new version changes behaviour, not the schema.
Options considered
| Option | Gain | Cost | Wrong when |
|---|---|---|---|
| A. Rolling update with defaults | No new tooling | Money errors reach users as pods turn over | Wrong totals are expensive |
| B. Blue-green | Instant switch back | Doubles checkout capacity during verification | Cost matters and the bug is subtle, not total |
| C. Canary at 5%, then 25%, then full | Few users see a wrong total | Needs metrics and a control group | Traffic is too low to judge in the window |
The decision
Option C. A rounding error is a correctness problem that no readiness probe sees, so exposure must stay small until a business metric agrees. The canary compares the new pods against the stable pods on checkout errors, latency and one correctness signal: the share of orders whose total differs from a recomputation of the old rule. The schema is unchanged, so rollback is a reroute.
Rollout and verification
Step one routes 5% and pauses for ten minutes; step two routes 25% and pauses until a person promotes. Alerts watch the canary population separately from the whole service, as the SRE Workbook advises. Promotion happens only when error rate, latency and total-mismatch rate stay within thresholds written into the release ticket beforehand, not chosen after looking at the graphs.
The 2 a.m. failure
The page reads: "Checkout Deployment has ProgressDeadlineExceeded". A later release of the checkout service references a configuration key that does not exist in production, so the new pods start and then fail their readiness probe. The old pods keep serving, so nobody sees an outage; the rollout simply stops. The documentation says Kubernetes "takes no action on a stalled Deployment other than to report" ProgressDeadlineExceeded, which defaults to 600 seconds, so nothing retries or reverts it for you.
First checks: kubectl rollout status deployment/checkout, then the new pods' events and logs. Mitigation: kubectl rollout undo deployment/checkout. Follow-up: validate configuration at start-up, and alert on the stalled condition so it is found before the next deploy stacks on top.
Architect's notes
- Ask what a bad release costs per minute before choosing; the answer picks the strategy.
- Gate on readiness, then on business signals. A pod that answers 200 can still compute the wrong total.
- Keep the old version around until the new one has survived a normal peak.
- Treat the schema as a separate, earlier release, and rehearse the rollback.
Common mistakes
- Assuming a rollback undoes data changes. It undoes the code.
- Canarying with too little traffic to see an error rate move.
- Judging a canary against the past, not against a simultaneous control.
- A readiness probe that checks nothing, so rolling updates replace healthy pods with broken ones.
- Paying for blue-green and sharing a database schema that only the new version supports.
Key takeaways
- A strategy decides how fast traffic moves and how many users a bad build can reach.
- Kubernetes rolls out by default: surge rounds up, unavailability rounds down, both default to 25%.
- Blue-green trades a second environment for a one-step switch and rollback.
- A canary needs representative traffic, few attributable metrics and a control group.
- Compatibility between neighbouring versions, especially the schema, matters more than the strategy.
- A stalled rollout leaves old pods serving and is only reported, so alert on it.
Practice exercises
Exercise 1 (20 min). For a Deployment of 12 replicas with maxSurge: 25% and maxUnavailable: 25%, compute the largest pod count and the smallest available count using the rounding rules above. Check by adapting the script.
Exercise 2 (40 min). Write a canary plan for ShopStream's order-tracking service: steps, pauses, three metrics, an abort rule, and what you compare against.
Exercise 3 (30 min). A release drops a column the old version still reads. Write the three releases that make it safe.
Related reading
- Feature flags: release a behaviour to a share of users without a deployment.
- Schema evolution and zero-downtime migrations: the expand, migrate, contract sequence.
- Health checks: liveness, readiness and startup: the gate that rolling updates depend on.
- Alerting and on-call: which release signals deserve a page.
- Observability and SLOs: the metrics a canary judges.
- Blue-green, canary and rollbacks on the front end: the other side of this topic, where the "pointer" is a build and old tabs outlive the switch.
Official documentation
- Kubernetes: Deployments (rolling update,
maxSurge,maxUnavailable, rollback,progressDeadlineSeconds). - Kubernetes: Service and liveness, readiness and startup probes.
- Argo Rollouts: BlueGreen and Canary.
- Martin Fowler: BlueGreenDeployment and CanaryRelease.
- Google SRE Workbook: Canarying Releases.