Rolling updates and rollbacks
How a Deployment swaps Pods between ReplicaSets under maxSurge and maxUnavailable, how readiness gates each step, how stuck rollouts show, and how undo works.
Rolling updates and rollbacks
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A rolling update scales the new ReplicaSet up and the old one down in steps. maxSurge caps how many extra Pods may exist; maxUnavailable caps how many of the desired count may be not ready. Both default to 25%.
- Each step waits for new Pods to be Ready (and stay Ready for minReadySeconds). Without a real readiness probe, Ready means only that the process started, and broken versions roll straight out.
- A rollout that makes no progress for progressDeadlineSeconds (600 by default) gets Progressing=False, ProgressDeadlineExceeded. Kubernetes does not roll back on its own; kubectl rollout status exits non-zero so CI can.
- kubectl rollout undo scales a previous ReplicaSet back up, as a rolling update in reverse, and renumbers that revision. It does not touch your files, so fix Git too.
- Recreate stops all old Pods before starting new ones. Use it only when two versions must never run together.
Changing the tyres while driving
You have four Pods serving traffic on version 2.0.0 and want 2.1.0. The crude way is to delete all four and start four new ones. That is an outage, however short. The careful way is to replace them a few at a time, and only remove an old Pod once its replacement is actually serving. The deployment strategies lesson in devops compared rolling, blue-green and canary releases in general. This lesson is how a Kubernetes Deployment does the rolling one, step by step.
Two knobs: maxSurge and maxUnavailable
A rollout, as the last lesson showed, moves replicas from the old ReplicaSet to a new one. Two numbers bound each step:
- maxSurge: how many Pods above
replicasmay exist at once. Extra capacity spent to go faster. - maxUnavailable: how many of the
replicasmay be not Ready at once. Capacity you are willing to lose.
Both default to 25%. Percentages are converted to Pods, surge rounding up and unavailable rounding down, and they cannot both be zero. Common settings:
| Setting | Behaviour |
|---|---|
maxSurge: 1, maxUnavailable: 0 |
Never below full capacity; one extra Pod at a time. Safe, slow, needs spare room. |
maxSurge: 0, maxUnavailable: 1 |
No extra Pods; capacity dips by one. For tight clusters. |
25% / 25% (default) |
A balance, faster on large Deployments. |
Watching one rollout
The lab Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders
spec:
replicas: 4
progressDeadlineSeconds: 30
strategy:
type: RollingUpdate
rollingUpdate: {maxSurge: 1, maxUnavailable: 0}
selector:
matchLabels: {app: orders}
template:
metadata:
labels: {app: orders}
spec:
containers:
- name: orders
image: ghcr.io/example/orders:2.0.0
The lab’s nodes run no containers, so a small script played the kubelet: every two seconds it marked any new Pod Running and Ready. Everything else was the real Deployment controller. After kubectl set image deploy/orders orders=ghcr.io/example/orders:2.1.0, the ReplicaSets (desired/ready) looked like this:
step 1: 2.1.0=1/ 2.0.0=4/4
step 2: 2.1.0=2/1 2.0.0=3/3
step 3: 2.1.0=3/2 2.0.0=2/2
step 4: 2.1.0=4/3 2.0.0=1/1
step 5: 2.1.0=4/4 2.0.0=0/
deployment "orders" successfully rolled out
That is maxSurge: 1, maxUnavailable: 0 exactly. One surge Pod first; each time a new Pod turned Ready, one old Pod went and one more new Pod was created. Ready Pods never dropped below four.
Readiness is the gate
The controller only moves on when new Pods are Ready, and, if you set minReadySeconds, stay Ready that long. Ready comes from the readiness probe. With no probe, a Pod is Ready as soon as its containers start. A version that boots and then fails every request rolls out completely, because nothing told the Deployment it was bad. The probe and minReadySeconds are your quality check; the strategy only enforces the pace.
Old Pods leave through normal graceful termination, so connection draining depends on pod termination and graceful shutdown being right too.
When a rollout gets stuck
Next, an image that never became Ready, 2.2.0-broken; the script left those Pods alone. With maxUnavailable: 0, the controller created one surge Pod and then could do nothing else:
t=5s: 2.1.0=4/4 2.0.0=0/ 2.2.0-broken=1/
t=37s: 2.1.0=4/4 2.0.0=0/ 2.2.0-broken=1/
Available=True MinimumReplicasAvailable: Deployment has minimum availability.
Progressing=False ProgressDeadlineExceeded: ReplicaSet "orders-f797855cf" has timed out progressing.
Users never saw 2.2.0: all four 2.1.0 Pods kept serving. After the 30-second progressDeadlineSeconds (600 by default), the Deployment’s Progressing condition turned False, and kubectl rollout status failed:
error: deployment "orders" exceeded its progress deadline
Kubernetes stops there. It does not roll back by itself. The condition and the non-zero exit code are signals for you or your pipeline: kubectl rollout status --timeout=5m in CI is the cheapest safety net there is. Automated rollback on metrics is what progressive delivery tools add.
Rolling back
$ kubectl rollout history deploy/orders
REVISION CHANGE-CAUSE
1 2.0.0 initial
2 bump to 2.1.0
3 bump to 2.2.0 (broken)
$ kubectl rollout undo deploy/orders
deployment.apps/orders rolled back
after undo: 2.1.0=4/4 2.0.0=0/ 2.2.0-broken=0/
REVISION CHANGE-CAUSE
1 2.0.0 initial
3 bump to 2.2.0 (broken)
4 bump to 2.1.0
Undo copied revision 2’s template back into the Deployment. That template still hashes to the 2.1.0 ReplicaSet, so the rollback was an ordinary rolling update in reverse: the broken ReplicaSet went to zero and revision 2 was renumbered 4. --to-revision=N picks a specific one. The CHANGE-CAUSE column comes from the kubernetes.io/change-cause annotation, set here by hand; the old --record flag is deprecated.
On a Deployment managed with kubectl apply, kubectl warns that undo “will not update the kubectl.kubernetes.io/last-applied-configuration annotation”. The live object and your Git repo now disagree. Revert the commit, or the next apply reintroduces the bug. In GitOps setups, roll back by reverting in Git instead.
Pause, resume and Recreate
kubectl rollout pause stops the controller from acting on template changes, so you can make several edits (image, env, resources) and release them as one rollout with kubectl rollout resume.
strategy: {type: Recreate} scales the old ReplicaSet to zero, waits for its Pods to terminate, then starts the new ones. There is downtime by design. Use it when two versions must never run side by side, such as an app that takes an exclusive lock or runs an incompatible schema migration on start.
About the video
The embed is TheCodeAlchemist’s “Kubernetes Rolling Updates Explained: Zero Downtime Strategy” (August 2026, 24 minutes). Its chapters build the idea up properly: desired against current state, why the obvious release strategy causes downtime, why a new version gets its own ReplicaSet while the old one is scaled to zero, maxSurge and maxUnavailable, what saves you when the new version has a readiness bug, and why a rollback is a rolling update in reverse, followed by a demo with maxSurge: 1, maxUnavailable: 0, rollout status and rollout undo. That is close to this lesson’s structure. It uses a Spring Boot app, and its point about dropped in-flight requests belongs partly to the graceful shutdown lesson. English was judged from the “English (US) original” audio track. CyberRavindra’s video in deeper also compares Recreate with RollingUpdate. A thorough DevOps Pro rollback guide was rejected because its original audio is Hindi.
What was run: both rollouts, the stuck one with its ProgressDeadlineExceeded condition, rollout status, history and undo ran against a local v1.37.3 control plane on 2026-11-28. Its nodes run no containers, so Pod readiness was written into Pod status by a script standing in for the kubelet, and another script renewed the node’s Lease; the Deployment controller’s decisions were real.
Where this fits
Deployments treat Pods as interchangeable. Some workloads need each Pod to keep its own name and disk: StatefulSets.
Check yourself
A 4-replica Deployment has maxSurge: 1 and maxUnavailable: 0. How does the rollout proceed?
The new ReplicaSet gets one Pod (five in total). When it is Ready, the old ReplicaSet drops to three. Repeat four times. Capacity never drops below four Ready Pods, and never more than five Pods exist.
You push an image that crashes on start. With maxUnavailable: 0, what happens to traffic, and what tells you something is wrong?
The surge Pod never becomes Ready, so no old Pod is removed and users keep hitting the old version. After progressDeadlineSeconds, the Deployment's Progressing condition turns False with ProgressDeadlineExceeded, and kubectl rollout status exits with an error. The rollout stays stuck until you undo or fix it.
Why is a correct readiness probe the most important part of a safe rolling update?
The Deployment only knows a new Pod is good by its Ready condition. Without a probe that checks the app can serve, a Pod is Ready the moment its container starts, so a version that fails on its first request replaces every old Pod.
After kubectl rollout undo, your next kubectl apply from Git brings the broken version back. Why?
undo changed the live Deployment's template but not your manifest, and it doesn't even update the last-applied annotation, as kubectl warns. Git still says the broken image. Revert the commit so the source of truth matches.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.