World map

 

BM: Baca dalam Bahasa Melayu

World K2: Trays & Orders

Rolling updates and rollout undo

You will learn: to ship a new version with no downtime, and to undo a bad one fast.

Checked with Kubernetes 1.37 on 31 Oct 2026

The problem

Lunch rush. The new menu, nginx 1.30, is ready. If you close the stall to swap trays, hungry customers walk away. What do you want?

Pick one answer.

Watch

You are here: cluster kind-dev namespace default
After set image, a new pod is created while the 3 old ones keep running. When the rollout finishes, the old ReplicaSet has 0 pods and the new one has 3. Terminal output: $ kubectl set image deployment/shop web=nginx:1.30-alpine deployment.apps/shop image updated $ sleep 3 $ kubectl get pods NAME READY STATUS RESTARTS AGE shop-747bf9cf8-55jjq 1/1 Running 0 25s shop-747bf9cf8-5kcvh 1/1 Running 0 25s shop-747bf9cf8-z89h7 1/1 Running 0 25s shop-7786946f68-dhwxr 0/1 ContainerCreating 0 3s $ kubectl rollout status deployment/shop --timeout=180s Waiting for deployment "shop" rollout to finish: 1 out of 3 new replicas have been updated... Waiting for deployment "shop" rollout to finish: 2 out of 3 new replicas have been updated... Waiting for deployment "shop" rollout to finish: 1 old replicas are pending termination... deployment "shop" successfully rolled out $ kubectl get rs NAME DESIRED CURRENT READY AGE shop-747bf9cf8 0 0 0 49s shop-7786946f68 3 3 3 27s

kubectl set image writes a new image into the order. A rolling update: Swap the copies one at a time, like changing cooks one by one. The stall never closes. starts. One new tray comes in, one old tray leaves, again and again.

Try it

Your turn. Ship nginx 1.30 to the shop. Then wait for the rollout to finish.

You are here: cluster kind-dev namespace default

Want 3. See 3. All good.

Want3written on the order for shop
See33 ready
Do All goodGaps fixed: 0
Stalls: 3. Trays: 3 (3 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen
  • shop·55jjq
  • shop·z89h7
dev-worker2Open
  • shop·5kcvh
Time: +0s (sped up)

Watch

You are here: cluster kind-dev namespace default
rollout history lists revision 1 and revision 2. Terminal output: $ kubectl set image deployment/shop web=nginx:1.30-alpine deployment.apps/shop image updated $ kubectl rollout status deployment/shop --timeout=180s Waiting for deployment "shop" rollout to finish: 1 out of 3 new replicas have been updated... Waiting for deployment "shop" rollout to finish: 2 out of 3 new replicas have been updated... Waiting for deployment "shop" rollout to finish: 1 old replicas are pending termination... deployment "shop" successfully rolled out $ kubectl rollout history deployment/shop deployment.apps/shop REVISION CHANGE-CAUSE 1 <none> 2 <none>

Each new template gets a revision: A numbered version of a Deployment's pod template. rollout undo goes back to one. number. The old ReplicaSet stays, empty, so going back is quick.

Predict

A teammate ships nginx:1.299. That tag does not exist. What happens to the 3 old trays?

Pick one answer.

Try it

It happened. The new tray shows ErrImagePull, then ImagePullBackOff. Plain words: that image cannot be fetched. Undo the rollout.

You are here: cluster kind-dev namespace default

Want 3. See 4. Remove 1.

Want3written on the order for shop
See43 ready
Do Remove 1Gaps fixed: 0
Stalls: 3. Trays: 4 (3 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen
  • shop·2g4l2
  • shop·v62jm
dev-worker2Open
  • shop·fxdpqImagePullBackOff
  • shop·57nrg
Time: +0s (sped up)

Check

Build the command that goes back to revision 1 exactly.

Tap the pieces in the right order.

…

You did it!

You can now ship a new version with no downtime, and undo a bad one.

Go deeper (optional)

After rollout undo, kubectl prints a Warning: the cluster changed, but your file did not. Fix the file in Git too, or the next apply brings the bug back. By default, a rollout adds up to 25% extra trays. It takes away at most 25%.

Real rep (optional): on a throwaway cluster, set a bad image, then undo it.