🎓 A1Learner
🔍
0 of 51 lessons completed

Kubernetes: Rolling Updates

A rolling update replaces pods one batch at a time. The app stays up while the new version takes over.

Start the update

One command points the Deployment at the new image. Kubernetes starts the replacement straight away.

kubectl set image deployment/web api=web:v2

Watch the rollout

The status command waits for the new pods to become ready. It reports success only when the rollout is complete.

kubectl rollout status deployment/web

Check the new pods

The pod list shows the new pods running. The old pods are gone.

kubectl get pods -l app=web

Undo a bad release

The undo command returns to the previous version. It runs the same rolling swap in reverse.

kubectl rollout undo deployment/web

Example

kubectl set image deployment/web api=web:v2
kubectl rollout status deployment/web
kubectl get pods -l app=web

Key points

  • Rolling update: a Deployment strategy that swaps old pods for new pods in small batches
  • Use kubectl set image to point a Deployment at a new container image
  • Use kubectl rollout status to watch the update finish or stall
  • Use kubectl rollout history to list the past versions of a Deployment
  • Use kubectl rollout undo to return to the previous version when a release is bad
  • A rolling update keeps some pods running while others are replaced
  • A bad image stops the rollout instead of taking the whole app down at once

In this example, the first command updates the image to version 2. The second command watches the rollout until it finishes. The third command lists the pods. The output shows two new pods running version 2 with zero restarts.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What command returns a Deployment to its previous version after a bad release?