Kubernetes rollouts
What a rollout actually is
When you change the pod template (usually the image), the Deployment controller creates a new ReplicaSet for it. It then steps the new one up and the old one down. The old ReplicaSet isn't deleted: it's kept at zero replicas, which is what makes kubectl rollout undo possible.
A Service doesn't know about versions. It sends traffic to every pod that matches its selector and is Ready. That one rule is why readiness probes matter so much.
Playground: maxSurge and maxUnavailable
Change a value and the scene restartsStep 1 of 5: Steady state. 4 v1 pods share all traffic behind the Service.
- Availability
- 100%
- No downtime
- Pods running
- 1.00×
- Peak 1.00× of normal
- Blast radius
- —
- Inject a bug to measure
- Time to recover
- —
- No incident
Probes and graceful shutdown
Should this pod get traffic right now? Failing removes it from the Service, but it isn't restarted. This is what makes a rolling update safe.
Is the process wedged? Failing restarts the container. Keep it simple: never check a downstream dependency here, or one database blip restarts everything.
Has it finished booting? Holds off the other probes until it passes, so slow starters aren't killed while warming up.
# Change the image → new ReplicaSet → rolling update begins
kubectl set image deployment/shop shop=registry.example.com/shop:2.0.0
kubectl rollout status deployment/shop # block until done (great in CI)
kubectl rollout history deployment/shop # one revision per ReplicaSet
kubectl rollout pause deployment/shop # freeze mid-rollout
kubectl rollout resume deployment/shop
kubectl rollout undo deployment/shop # back to the previous ReplicaSet
kubectl rollout undo deployment/shop --to-revision=3
kubectl get rs -l app=shop # watch old scale down, new scale upWhat's built in, and what isn't
| You want… | Plain Kubernetes | How |
|---|---|---|
| Recreate | Built in | strategy.type: Recreate |
| Rolling update | Built in | strategy.type: RollingUpdate (the default) |
| Blue-green | By hand | Two Deployments plus a Service selector switch, by hand. Argo Rollouts automates it. |
| Canary by pod ratio | By hand | Two Deployments behind one Service. 1 of 10 pods ≈ 10%. |
| Canary by exact % | Needs tooling | Gateway API HTTPRoute weights, ingress-nginx, or a service mesh |
| Automated analysis and rollback | Needs tooling | Argo Rollouts or Flagger, plus Prometheus or Datadog |
| Traffic mirroring | Needs tooling | Istio, or Gateway API's RequestMirror filter |
| Header or cookie routing (A/B) | Needs tooling | Gateway API matches, ingress annotations, or a mesh |
| Feature flags | Needs tooling | In your app: OpenFeature, LaunchDarkly, Unleash, flagd… |