IN·84
Kubernetes Deployment Strategy
Shipping changes without outages: rolling updates in detail (maxSurge, maxUnavailable, readiness gating, progress deadlines), recreate, blue/green, canary releases and traffic splitting, progressive delivery with automated analysis (Argo Rollouts, Flagger), shadow traffic and A/B tests, feature flags as the separation of deploy from release, rollback (and why database changes make it hard: expand/contract), immutable images and promotion across environments, and configuration management with Helm, Kustomize and GitOps.
Start here: changing the version without anyone noticing
Deploying is the riskiest thing you do routinely
Most outages start with a change: a new version, a configuration push, a feature flag. A deployment strategy decides how the new version replaces the old one, and so what users experience while it happens and how fast you can undo it. The goals: no failed requests during the change, a small blast radius if the new version is bad, and a fast, reliable way back.
A rolling update, watched
A Deployment with 4 replicas, maxSurge: 1 (one extra pod allowed during the update) and maxUnavailable: 0 (never fewer than 4 ready), a readiness probe, and a short preStop pause. Changing anything in the pod template (here an environment variable) starts a new rollout:
$ kubectl set env deploy/menu VERSION=v2 # change the pod template: a rolling update starts
Waiting for deployment "menu" rollout to finish: 1 out of 4 new replicas have been updated...
Waiting for deployment "menu" rollout to finish: 2 out of 4 new replicas have been updated...
Waiting for deployment "menu" rollout to finish: 3 out of 4 new replicas have been updated...
Waiting for deployment "menu" rollout to finish: 1 old replicas are pending termination...
deployment "menu" successfully rolled out
257 requests: v1 122, v2 135
0s v1:38
1s v1:38
2s v1:29 v2:9
3s v1:14 v2:25
4s v1:3 v2:38
5s v2:39
6s v2:24
The Deployment created a new ReplicaSet for v2 and moved one pod at a time: start a v2 pod, wait until it's ready, then retire a v1 pod, and repeat. For about three seconds both versions served traffic side by side, and not one request failed. Two consequences to design for: during a rollout both versions run at once (so database schemas and APIs must be compatible with both), and a rollout is only as safe as its readiness probe and shutdown handling (the lab removes them and counts the errors).
Rolling back
$ kubectl rollout history deploy/menu
REVISION CHANGE-CAUSE
1 <none>
2 <none>
$ kubectl rollout undo deploy/menu
deployment.apps/menu rolled back
307 requests: v1 152, v2 155
Kubernetes keeps old ReplicaSets (10 by default, revisionHistoryLimit), so undo is just another rolling update back to the previous template, again with no failed requests. In a GitOps setup you'd instead revert the commit and let Argo CD or Flux apply it, so Git stays the source of truth (note the warning kubectl printed about last-applied-configuration: mixing imperative undo with declarative apply causes drift).
The strategies
| Strategy | How | Runs both versions? | Rollback | Main cost or risk |
|---|---|---|---|---|
| Recreate | Stop all old, then start new | No | Redeploy old | Downtime |
| Rolling update | Replace pods gradually | Yes, briefly | Roll back gradually | Mixed versions; slow undo for large fleets |
| Blue/green | Run a full new copy; switch traffic at once | Both deployed, one live | Switch back instantly | Double capacity during the switch |
| Canary | Send a small share of traffic to the new version, then increase | Yes, deliberately | Stop the canary | Needs metrics to judge it |
| Progressive delivery | Automated canary steps gated on metrics (Argo Rollouts, Flagger) | Yes | Automatic on bad metrics | Tooling and good SLO metrics |
| Feature flags | Deploy code dark; enable per user/percentage at run time | Same binary | Turn the flag off | Flag debt and testing combinations |
How deep to go in deployment strategy
Volume 17 defines six mastery levels. For this chapter they look like this; the chapter aims at L3 everywhere, and its lab at L4.
| Level | What you can do |
|---|---|
| L1 | Explain recreate, rolling, blue/green, canary and feature flags |
| L2 | Configure rolling updates with probes, surge/unavailable, graceful shutdown and rollbacks |
| L3 | Explain the shutdown race, mixed-version compatibility, expand–contract migrations and traffic splitting |
| L4 | Diagnose errors during deploys, stuck rollouts, bad canaries and config drift |
| L5 | Design a release process: strategies per service, gates, metrics, flags and rollback policy |
| L6 | Run progressive delivery across many teams with automated analysis and change management |
What can go wrong in a deployment
A deployment replaces running software with new software. Each step has its own failure mode:
- The new version is broken (bug, bad config, missing secret, incompatible dependency): needs fast detection and rollback.
- The transition itself drops requests: connections cut during termination, pods receiving traffic before they're ready, capacity dipping below demand.
- Old and new versions run at the same time (in every strategy except recreate): they must be compatible with each other, with the database schema, with message formats and with clients' cached assets.
- Changes that aren't reversible: a database migration that drops a column, a message format consumers can't read, data written in a new format.
Good deployment practice reduces each of these: small, frequent changes; automated health gates; strategies that expose new versions to little traffic at first; and rollback paths that actually work.
Recreate
strategy: type: Recreate stops all old pods, then starts the new ones.
- Downtime between old pods stopping and new pods becoming ready.
- Use when two versions must not run concurrently: a singleton that holds an exclusive lock or license, an app that can't share a database schema version, dev environments, or
ReadWriteOncevolumes that only one pod can mount.
Rolling updates
Mechanics
The Deployment default. The controller creates a new ReplicaSet and gradually scales it up while scaling the old one down, gated by two parameters:
maxSurge: how many pods above the desired count may exist during the update (absolute or %, default 25%).maxUnavailable: how many pods below the desired count may be unavailable (default 25%).
A new pod counts as available only once it's Ready (readiness probe passing) for minReadySeconds. So readiness probes directly control rollout safety: a new version that never becomes ready stalls the rollout instead of replacing healthy pods.
Choosing the parameters:
| Setting | Behaviour | Use when |
|---|---|---|
maxSurge: 1, maxUnavailable: 0 |
Never below desired capacity; one extra pod at a time | Capacity is tight; safest default for services |
maxSurge: 25%, maxUnavailable: 0 |
Faster with full capacity, needs spare cluster room | Most services |
maxSurge: 0, maxUnavailable: 1 |
No extra pods (no spare capacity or quota), capacity dips by one | Resource-constrained clusters |
Large maxSurge (100%) |
Brings up a whole new set then shifts | Fast rollouts, roughly blue/green-like without traffic control |
Making rolling updates safe
- Readiness probes that reflect the ability to serve, plus a
startupProbefor slow starts. - Graceful termination: preStop delay, SIGTERM handling and a sufficient grace period (chapter 83).
minReadySeconds(e.g. 10–30 s) so a pod that crashes shortly after becoming ready doesn't count.progressDeadlineSeconds(default 600): if no progress, the Deployment'sProgressingcondition becomes false (ProgressDeadlineExceeded); CI can detect this withkubectl rollout statusand roll back. Kubernetes doesn't roll back automatically.- PodDisruptionBudgets protect against node drains happening during the rollout.
- Connection-level concerns: long-lived connections (WebSockets, gRPC streams) stay pinned to old pods until closed; set connection max age on servers so clients rebalance (
MaxConnectionAgein gRPC).
kubectl set image deploy/orders orders=ghcr.io/acme/orders@sha256:… -n shop # (or apply new YAML / GitOps)
kubectl rollout status deploy/orders -n shop --timeout=5m
kubectl rollout history deploy/orders -n shop
kubectl rollout undo deploy/orders -n shop # back to the previous ReplicaSet
kubectl rollout undo deploy/orders -n shop --to-revision=7
kubectl rollout pause|resume deploy/orders -n shop
kubectl rollout restart deploy/orders -n shop # re-create pods with the same spec
Limitation: a rolling update shifts traffic in proportion to pod counts and moves forward as long as pods are ready, even if the new version returns errors or is slow. Readiness isn't correctness. That's what canaries and analysis add.
Blue/green
Run two complete environments: blue (current) and green (new). Deploy green, test it in place (smoke tests, internal traffic), then switch all traffic at once by changing a router: a Service selector, a Gateway route, a load-balancer target group, DNS. Keep blue running for a while so rollback is just switching back.
Pros and cons:
- ✓ Instant cutover and instant rollback; the new version is fully tested in production infrastructure before taking user traffic; no mixed versions serving users (mostly).
- ✗ Double capacity during the switch (costly for large services).
- ✗ The switch is all at once: if green has a bug that only real traffic reveals, every user hits it (until you flip back).
- ✗ Shared state still constrains it: both environments usually share databases, queues and caches, so schema and message compatibility rules still apply; in-flight sessions and long connections need draining.
In Kubernetes: two Deployments (orders-blue, orders-green) and a Service whose selector switches version: blue → version: green; or a Gateway HTTPRoute switching backendRefs; or Argo Rollouts' blueGreen strategy (active and preview Services, optional automated analysis before promotion).
Canary releases
The idea
Route a small fraction of real traffic (1%, 5%, 10%…) to the new version, compare its health with the stable version, and increase the share step by step if it looks good; roll back automatically if it doesn't. Named after the canaries miners used to detect gas: a small exposure warns you before everyone is affected.
How traffic gets split
| Mechanism | Precision | Notes |
|---|---|---|
| Pod ratio (1 canary pod among 9 stable, same Service) | Coarse (10%, 11%…) | No extra infrastructure; limited control |
Gateway / ingress weights (HTTPRoute weight, NGINX/Traefik/ALB weighted target groups) |
Percentage | Edge traffic only |
| Service mesh (Istio VirtualService, Linkerd/SMI or HTTPRoute via GAMMA) | Exact %, header-based routing, east-west traffic | Can also route specific users (employees, a header, a cookie) to the canary |
| Feature flags (application level) | Per user, per tenant, per region | Separates deploy from release (below) |
Sticky assignment matters: a user flipping between versions on each request sees inconsistent behaviour (and for UI changes, broken asset references). Route by a consistent hash of user ID or a cookie when the change is user-visible.
What to measure
Analysis compares canary metrics with thresholds or with the stable version over the same period:
- Golden signals: request error rate (5xx and important 4xx), latency percentiles (p95/p99), saturation (CPU, memory, restarts, OOM kills).
- Business metrics: checkout success, payments authorised, sign-ups.
- Logs: new error types, panics, exceptions.
- Statistical care: at 1% traffic, small samples make metrics noisy. Run each step long enough, or compare against a baseline pod set of the old version created at the same time (to remove "time of day" effects), as Netflix's Kayenta does.
Progressive delivery
Progressive delivery is the umbrella term (coined around 2018) for gradual, metric-gated, automatically reverted rollouts: canaries, blue/green with analysis, feature-flag ramps. In Kubernetes:
- Argo Rollouts: a
Rolloutresource (drop-in replacement for Deployment) withcanaryorblueGreenstrategies, traffic routing through Gateway API, Istio, NGINX, ALB, SMI and others, andAnalysisTemplates querying Prometheus, Datadog, New Relic, CloudWatch, Kayenta, web hooks or Kubernetes Jobs. - Flagger (Flux project): watches a Deployment and automates canary, A/B or blue/green with a service mesh or ingress, with Prometheus-based metric checks and webhooks for load tests.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata: { name: orders, namespace: shop }
spec:
replicas: 10
selector: { matchLabels: { app.kubernetes.io/name: orders } }
template: { … } # same pod template as a Deployment
strategy:
canary:
canaryService: orders-canary
stableService: orders-stable
trafficRouting:
plugins:
argoproj-labs/gatewayAPI: { httpRoute: orders, namespace: shop }
analysis:
templates: [{ templateName: success-rate }]
startingStep: 1 # background analysis from step 1
steps:
- setWeight: 5
- pause: { duration: 10m }
- setWeight: 25
- pause: { duration: 10m }
- setWeight: 50
- pause: { duration: 10m }
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata: { name: success-rate, namespace: shop }
spec:
metrics:
- name: success-rate
interval: 1m
failureLimit: 2
successCondition: result[0] >= 0.99
provider:
prometheus:
address: http://prometheus.monitoring:9090
query: |
sum(rate(http_server_requests_seconds_count{app="orders",role="canary",status!~"5.."}[2m]))
/
sum(rate(http_server_requests_seconds_count{app="orders",role="canary"}[2m]))
Other release techniques
- Shadow (mirrored / dark) traffic: copy real requests to the new version and discard its responses (Istio/Envoy
mirror, NGINXmirror). Tests performance and correctness on real traffic with no user impact, but only for read-only or side-effect-free requests (or with side effects disabled), or you'll double-charge customers. - A/B testing: routes users into variants to measure product impact (conversion), with statistical rigour; it answers "is it better?", while a canary answers "is it safe?".
- Ring deployments: internal users → beta customers → region by region → everyone (Microsoft's approach), often combined with cell-based architectures to limit blast radius.
Feature flags: deploy is not release
A feature flag (toggle) is a runtime switch around new code. It decouples deployment (putting code in production) from release (exposing behaviour to users):
- Merge unfinished work behind a flag-off (trunk-based development, no long-lived branches).
- Release to employees, then 1%, 10%, 100% of users, or specific tenants, without redeploying.
- Kill switch: turn a misbehaving feature off in seconds, faster than any rollback.
- Ops toggles (disable expensive features under load), permission toggles (premium features), experiment toggles (A/B).
Tools: LaunchDarkly, Unleash, Flagsmith, ConfigCat, Split/Harness, GrowthBook, Flipt, cloud services (AWS AppConfig), with the vendor-neutral OpenFeature API (CNCF) and SDKs for most languages.
// Java: OpenFeature client, evaluation context targets users/tenants; provider can be any vendor
Client flags = OpenFeatureAPI.getInstance().getClient("orders");
EvaluationContext ctx = new ImmutableContext(userId, Map.of("tenant", new Value(tenantId)));
if (flags.getBooleanValue("new-pricing-engine", false, ctx)) {
return newPricing.quote(cart);
}
return legacyPricing.quote(cart);
// Go: OpenFeature
client := openfeature.NewClient("orders")
ctx := openfeature.NewEvaluationContext(userID, map[string]any{"tenant": tenantID})
if enabled, _ := client.BooleanValue(context.Background(), "new-pricing-engine", false, ctx); enabled {
return newPricing.Quote(cart)
}
return legacyPricing.Quote(cart)
# Python: OpenFeature
from openfeature import api
from openfeature.evaluation_context import EvaluationContext
client = api.get_client("orders")
ctx = EvaluationContext(targeting_key=user_id, attributes={"tenant": tenant_id})
quote = new_pricing(cart) if client.get_boolean_value("new-pricing-engine", False, ctx) else legacy_pricing(cart)
// Rust: OpenFeature
let client = OpenFeature::singleton().await.create_client();
let ctx = EvaluationContext::default().with_targeting_key(user_id).with_custom_field("tenant", tenant_id);
let quote = if client.get_bool_value("new-pricing-engine", Some(&ctx), None).await.unwrap_or(false) {
new_pricing(&cart)
} else {
legacy_pricing(&cart)
};
Discipline: every flag has an owner and an expiry; remove flags after full rollout (stale flags are tech debt and combinatorial test risk); default to the safe value when the flag service is unreachable; evaluate locally from cached rules rather than a network call per request.
Rollback
Mechanisms
| Layer | Rollback |
|---|---|
| Deployment | kubectl rollout undo (previous ReplicaSet) |
| Argo Rollouts / Flagger | Automatic abort on failed analysis; kubectl argo rollouts undo |
| Helm | helm rollback orders 41 |
| GitOps | git revert the change; Argo CD/Flux sync it (avoid manual cluster changes that GitOps will undo or fight) |
| Feature flag | Turn it off (fastest) |
| Blue/green | Switch router back |
Roll forward or back? Rolling back is usually fastest for regressions: "mitigate first, debug later". Rolling forward (a quick fix) is right when rollback is impossible or riskier (irreversible migration, data written in a new format).
Why rollbacks fail: state
Code is easy to roll back; state isn't. Rollback works only if the previous version can operate on whatever the new version did:
- Database schema: if v2 renamed or dropped a column, v1 breaks after rollback.
- Data formats: v2 wrote JSON documents, cache entries or messages in a new format v1 can't read.
- External side effects: emails sent, payments taken.
The answer is expand/contract (parallel change) migrations, keeping every step backward- and forward-compatible:
The same discipline applies to:
- APIs: add fields, don't remove or repurpose them; version when breaking.
- Events and messages: schema registry compatibility rules (Vol. 5 ch. 67).
- Caches: version cache keys (
v2:user:42) when the format changes. - Frontends: keep old static assets available for a while (users have old bundles loaded).
Run schema migrations as a separate, explicit step (a Job, a CI stage, Flyway/Liquibase/Atlas/sqlx/golang-migrate/Alembic), not automatically on every pod start where N replicas race to migrate.
Immutable images and promotion
Build once, deploy many
- Immutable artefacts: an image is built once per commit, tested, then promoted through environments (dev → staging → production) by digest. Never rebuild for production: a rebuild can pick up different dependencies or base layers.
- Immutable tags and digest pinning (chapter 81): a running pod's image can always be traced to a commit, scanned and reproduced.
- No changes inside running containers (no
kubectl exechot fixes, no SSH). If you need a fix, ship a new image through the pipeline; to debug, use ephemeral containers. - Immutable infrastructure generally: replace nodes and pods rather than patching them in place.
Configuration management
The same image runs everywhere, so configuration carries the differences between environments:
- Externalised configuration (twelve-factor): environment variables, mounted ConfigMaps, and secrets, never baked into images.
- Kustomize overlays or Helm values per environment, kept in Git:
deploy/
├── base/ # Deployment, Service, HPA, PDB: environment-neutral
│ └── kustomization.yaml
└── overlays/
├── staging/
│ ├── kustomization.yaml # images: digest; replicas: 2; patches: small limits
│ └── config.env
└── production/
├── kustomization.yaml # images: digest; replicas: 6; patches: zone spread, PDB
└── config.env
# deploy/overlays/production/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: shop
resources: [../../base]
images:
- name: ghcr.io/acme/orders
digest: sha256:3b1c… # promoted digest, updated by CI pull request
replicas:
- { name: orders, count: 6 }
configMapGenerator:
- name: orders-config
envs: [config.env] # hashed name → pods roll when config changes
patches:
- path: resources-prod.yaml
- Config changes are deployments too: version them, review them, roll them out gradually, and be able to roll them back. Many large outages were configuration pushes applied everywhere at once.
- Secrets via External Secrets / CSI / Sealed Secrets (chapter 83), referenced but not stored in plain text in Git.
- Policy checks in CI on rendered manifests (kubeconform for schema, kube-linter, Kyverno CLI or Conftest for policies, Trivy for misconfigurations) catch problems before they reach the cluster.
Choosing a strategy
| Strategy | Downtime | Extra capacity | Exposure to a bad version | Rollback speed | Complexity |
|---|---|---|---|---|---|
| Recreate | Yes | None | 100% | Redeploy | Lowest |
| Rolling update | No | Surge only | Grows with rollout | Rollout undo (minutes) | Low |
| Blue/green | No | 2× during switch | 100% at switch | Instant (flip) | Medium |
| Canary + analysis | No | Small | Starts at a few % | Automatic | Higher (traffic routing, metrics) |
| Feature flags | No | None | Any % / any segment | Seconds | Application-level discipline |
A typical mature setup: GitOps for all changes, immutable images by digest, rolling updates with good probes and termination for most services, canaries with automated analysis for critical, high-traffic services, feature flags for user-facing behaviour, and expand/contract for every schema and contract change.
Lab: five deployments under load
The volume's single-node k3s 1.37 cluster; tiffin:2.2 pods (which drain in-flight requests on SIGTERM); an in-cluster load generator calling the Service about 40 times a second with a 2-second timeout and recording the answering version or ERR. Each rollout uses maxSurge: 1, maxUnavailable: 0 unless stated.
Experiment 1: what makes a rolling update safe
The same v1 → v2 rollout of 4 pods, three ways:
readiness probe: no, preStop sleep 5 s: no 328 requests: ERR 6, v1 81, v2 241
readiness probe: yes, preStop sleep 5 s: no 324 requests: ERR 13, v1 69, v2 242
readiness probe: yes, preStop sleep 5 s: yes 516 requests: v1 172, v2 344
Only the last configuration had zero errors (and, without the timeouts, the load generator got through more requests). The failures come from a race during shutdown: when a pod is deleted, two things start at the same time and independently: the kubelet sends SIGTERM to the container, and the endpoints controller removes the pod from the Service, which then has to propagate to kube-proxy on every node (and to any ingress controller or load balancer). tiffin stops accepting new connections as soon as it gets SIGTERM, so for a moment the Service still sent connections to a pod that refused them. A preStop hook that waits a few seconds (here the built-in sleep action, available by default since Kubernetes 1.30; in images with a shell, sleep 5) delays SIGTERM until the pod has left every load balancer; the app then drains and exits. Readiness probes protect the other end of the rollout: new pods get traffic only once they can serve it. The rule: readiness probe + preStop delay + SIGTERM handling + a grace period longer than both.
Experiment 2: Recreate
386 requests: ERR 15, v1 232, v2 139
0s v1:37 … 4s v1:40
5s ERR:5 v1:35
6s ERR:9
8s ERR:1 v2:29
9s v2:40 …
All v1 pods stopped before any v2 pod started: about three seconds with no service (second 7 had no completed requests at all; each failed request waited for its 2-second timeout). Use Recreate only when two versions must never run together (an exclusive lock on a resource, a singleton consumer) and a short outage is acceptable.
Experiment 3: blue/green by switching a selector
Blue (v1) and green (v2) Deployments of 3 pods each, both running and ready; the Service's selector is patched from track: blue to track: green:
switched to green at +0 s
203 requests: v1-blue 34, v2-green 169
0s v1-blue:34 v2-green:6
1s v2-green:41
Traffic moved within the same second with no errors, and switching back would be just as fast because blue is still running. The price is double capacity during the switch, and the switch is all-or-nothing: if green has a bug, every user hits it until you switch back. Long-lived connections stay on blue until they close, so keep blue running for a while.
Experiment 4: a canary by replica ratio
4 stable v1 pods and 1 canary v2 pod, all selected by one Service:
620 requests: v1 487, v2-canary 133
The canary got 21% of requests, close to its 1-in-5 share of pods. That's the simplest canary, but the share is tied to replica counts (1% needs 100 pods) and is random per connection. Gateways and meshes (Gateway API HTTPRoute weights, Istio, Linkerd, NGINX canary annotations) split by weight or header independently of replicas, and progressive-delivery controllers (Argo Rollouts, Flagger) step the weight up automatically while comparing the canary's error rate and latency with the baseline.
Experiment 5: a bad version that never becomes ready
v3 has a broken readiness probe (it checks the wrong port), so its pods never become ready. With maxUnavailable: 0 and progressDeadlineSeconds: 30:
error: deployment "menu" exceeded its progress deadline
Available=True (MinimumReplicasAvailable)
Progressing=False (ProgressDeadlineExceeded)
menu-5db56ffc94-86w86 1/1 Running (four v2 pods)
menu-8b678c587-w8wgf 0/1 Running (one v3 pod, never ready)
1249 requests: v2 1249
after rollout undo: 4/4 ready
The rollout stopped after its first surge pod: no v2 pod was removed because no v3 pod became ready, so users saw only v2 and no errors. After 30 seconds the Deployment reported ProgressDeadlineExceeded, which CI/CD pipelines and GitOps tools use as the signal to fail the deploy and roll back. Kubernetes doesn't roll back automatically; kubectl rollout undo (or reverting the Git commit) did. This is why readiness probes and maxUnavailable: 0 matter even more for failed deploys than for successful ones.
Try it yourself
- Repeat experiment 1 with
terminationGracePeriodSeconds: 3and a/slowrequest in flight during the rollout. What happens to the request? - Install Argo Rollouts and run a canary with steps at 10%, 50% and 100%, with an analysis that fails if the error rate exceeds 1%.
- Do an expand/contract column rename across three deployments of a small app with PostgreSQL, rolling back after each step to prove it's safe.
- Put a feature flag (OpenFeature with a file provider) around a new menu field and enable it for 10% of users without redeploying.
Revision sheet: Kubernetes deployment strategy
Key ideas
- What goes wrong: bad code, bad config, capacity drops, shutdown races, incompatible versions running together, irreversible state changes.
- Recreate: simple, downtime, no mixing.
- Rolling update:
maxSurge,maxUnavailable, readiness gating,minReadySeconds,progressDeadlineSeconds, revision history. - Safe shutdown: readiness probe, preStop delay (endpoint propagation), SIGTERM draining,
terminationGracePeriodSeconds. - Blue/green: two full environments, instant switch and rollback, double capacity, connection draining.
- Canary: small traffic share, metrics comparison, weight- or header-based splitting via gateways/meshes; progressive delivery (Argo Rollouts, Flagger) with automated analysis; shadow traffic; A/B tests.
- Feature flags: deploy ≠ release; kill switches, percentage rollouts, targeting; OpenFeature; flag hygiene.
- Rollback: undo vs roll forward; why state (schemas, data formats, messages) blocks rollback; expand/contract migrations as separate steps.
- Promotion: build once, immutable images by digest, promote through environments; Helm, Kustomize, GitOps (Argo CD, Flux).
Numbers to remember
- Defaults: maxSurge 25%, maxUnavailable 25%, progressDeadlineSeconds 600, revisionHistoryLimit 10, grace period 30 s.
- Lab: no preStop gave 6–13 errors per rollout, readiness + preStop 0; Recreate ~3 s outage; blue/green switch within a second; a 1-in-5 canary got 21% of traffic; a never-ready version stalled with 0 errors and ProgressDeadlineExceeded after 30 s.
Pitfalls
- No preStop delay, so endpoint removal races SIGTERM.
- Readiness probes that pass before the app is warm.
- Grace periods shorter than drain time.
- Schema changes that break the previous version.
- Mixing
kubectl rollout undowith GitOps (drift). - Canaries without metrics, or metrics too noisy to decide.
Glossary
- ReplicaSet: keeps N identical pods; Deployments create one per template revision.
- maxSurge / maxUnavailable: limits above and below desired replicas during a rollout.
- preStop hook: action run before SIGTERM when a container is stopped.
- Progressive delivery: automated, metric-gated gradual release.
- Expand/contract: multi-step backward-compatible change.
- GitOps: Git as the source of truth, reconciled into the cluster by an agent.