Roll out and roll back safely

DevOps, Hands On20 minutesCosts moneySteps checked 14 November 2026By Cloud Hands On

In this task you'll release a new version with no downtime, and roll it back.

Changing a Deployment's pod template (a new image or setting) starts a rolling update: new pods start, old ones stop. maxUnavailable: 0 and maxSurge: 1 mean a new pod must be ready before an old one goes, and a readiness probe decides what ready means.

Kubernetes keeps old revisions, so kubectl rollout undo goes back in one command. progressDeadlineSeconds makes a stuck rollout report failure quickly.

Example. A bad image tag stalled SS Kaiser's release: the new pod couldn't pull its image, but maxUnavailable 0 kept the old pods serving. The on-call engineer ran rollout undo and nobody noticed.

Costs money. This task creates resources that are charged while they exist. Delete them as soon as you finish.

Before you start

You need: An AKS cluster. Time: 20 minutes.

Where to look

  1. kubectl
  2. rollout status
  3. rollout history
  4. rollout undo

Steps

  1. Add a readinessProbe (httpGet on / port 80) and set strategy.rollingUpdate to maxUnavailable 0 and maxSurge 1.
  2. Change the image or an env value and kubectl apply it.Or kubectl set image deploy/web web=<image>:<tag>.
  3. Watch it: kubectl rollout status deploy/web.
  4. Record why: kubectl annotate deploy/web kubernetes.io/change-cause="Release 2.1" --overwrite.
  5. Roll back: kubectl rollout history deploy/web, then kubectl rollout undo deploy/web.

Commands

# Connect kubectl to the cluster first
az aks get-credentials -g <group> -n <cluster>
kubectl set image deploy/web web=mcr.microsoft.com/azuredocs/aks-helloworld:v1
kubectl rollout status deploy/web
kubectl rollout history deploy/web
kubectl rollout undo deploy/web
kubectl patch deploy web -p '{"spec":{"progressDeadlineSeconds":120}}'

Watch out for

Cost
Uses the cluster you already pay for.
Security
Pin image tags; a moving tag can change what a rollback brings back.
Common mistakes
No readiness probe (traffic reaches pods that aren't ready), and the default 600-second progress deadline hiding a stuck rollout.

Clean up

Nothing extra beyond the cluster's own clean-up.

Words to know

Readiness probe
A check (such as an HTTP GET) that must pass before a pod gets traffic.
Rolling update
Replacing pods a few at a time.
Revision
A saved version of the pod template you can roll back to.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going