Thuta Learning
AdvancedDevOpsintermediate

Rolling Updates & Rollbacks

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand Rolling Updates & Rollbacks without feeling intimidated by them
  • Get comfortable running the kubectl commands/YAML yourself
  • Be able to apply this concept immediately in a real project

Let's think about it this way for a second

If you switched every pod to a new version all at once (a recreate strategy), there could be a brief gap where nothing is around to handle traffic — that's why a Deployment's default strategy is 'RollingUpdate': it creates one new pod, waits for it to become Ready, then removes one old pod, and keeps doing that gradually until everything is switched over — users never notice a single moment of downtime. If a bug slips into the new version, `kubectl rollout undo` lets you instantly switch back to the previous version (Kubernetes keeps the last 10 revisions of deployment history by default).

Let's connect this to a real scenario

Something like `kubectl set image deployment/web-deployment web=my-app:v2` kicks off a rolling update as soon as you change the image version — you can track its progress with `kubectl rollout status`. If v2 turns out to have a bug, `kubectl rollout undo deployment/web-deployment` gets you back to v1 instantly — it's the go-to command in a production incident.

Let's look at it together

bash
# Update to a new image version (triggers rolling update)
kubectl set image deployment/web-deployment web=my-app:v2

# Watch the rollout happen
kubectl rollout status deployment/web-deployment

# See rollout history
kubectl rollout history deployment/web-deployment

# Something went wrong? Roll back instantly
kubectl rollout undo deployment/web-deployment
You should see
Waiting for deployment "web-deployment" rollout to finish: 1 out of 3 new replicas have been updated...
deployment "web-deployment" successfully rolled out

5-Minute Try-It

Change web-deployment's image to a new version (for example, `nginx:alpine` to `nginx:latest`) and watch the rollout status — then switch it back with `rollout undo`.

A Quick Word of Caution

Be extra careful when pairing a rolling update with a breaking database schema change — during the window where old and new pods coexist, your code needs to support both schema versions at once.

Easy traps

  • Not accounting for the fact that during a rolling update (while old and new pods are mixed together), incompatible API versions can cause errors (e.g. a v1 pod not matching a v2 database schema)
  • Assuming `rollout undo` will always save you without checking whether the deployment history actually has it — once you're past the revision history limit, you can't undo to a version that's too old

Now Try It Yourself

Change web-deployment's image to a new version (for example, `nginx:alpine` to `nginx:latest`) and watch the rollout status — then switch it back with `rollout undo`.

You'll know it worked when: Waiting for deployment "web-deployment" rollout to finish: 1 out of 3 new replicas have been updated... deployment "web-deployment" successfully rolled out

Rolling Updates & Rollbacks | Thuta Learning