Skip to content
Ship It
Learn/Deep dive

Kubernetes rollouts

A Deployment doesn't replace pods directly. It runs two ReplicaSets and scales one up while the other scales down. Two numbers decide how fast that happens and what it costs.

What a rollout actually is

Deploymentreplicas: 4ReplicaSet (old)4 → 2 · scaling downReplicaSet (new)0 → 3 · scaling upv1v1v1v1v2v2v2dashed = terminating (old) or starting (new)

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 restarts
At most5 pods(replicas + maxSurge)At least4 ready(replicas − maxUnavailable)
Try:
USERSROUTINGPODSServicev2: 0%v1SERVINGv1SERVINGv1SERVINGv1SERVING
0.0s / 16s

Step 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
v1 (current)v2 (new)StartingSucceededFailed

Probes and graceful shutdown

readinessProbe

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.

livenessProbe

Is the process wedged? Failing restarts the container. Keep it simple: never check a downstream dependency here, or one database blip restarts everything.

startupProbe

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 up

What's built in, and what isn't

You want…Plain KubernetesHow
RecreateBuilt instrategy.type: Recreate
Rolling updateBuilt instrategy.type: RollingUpdate (the default)
Blue-greenBy handTwo Deployments plus a Service selector switch, by hand. Argo Rollouts automates it.
Canary by pod ratioBy handTwo Deployments behind one Service. 1 of 10 pods ≈ 10%.
Canary by exact %Needs toolingGateway API HTTPRoute weights, ingress-nginx, or a service mesh
Automated analysis and rollbackNeeds toolingArgo Rollouts or Flagger, plus Prometheus or Datadog
Traffic mirroringNeeds toolingIstio, or Gateway API's RequestMirror filter
Header or cookie routing (A/B)Needs toolingGateway API matches, ingress annotations, or a mesh
Feature flagsNeeds toolingIn your app: OpenFeature, LaunchDarkly, Unleash, flagd…