We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Rollbacks

When a rolling update replaces the old ReplicaSet, it gets scaled down to 0 and can be kept around, along with its pod template. By default, Kubernetes retains 10 old ReplicaSets. The deployment's spec.revisionHistoryLimit controls how many to keep; any ReplicaSets beyond that limit are eventually deleted, starting with the oldest.

But in general, when a deploy goes bad, you don't need to figure out what the old config was. You can just roll back with kubectl rollout undo:

kubectl rollout undo deployment synergychat-web

This scales the previous revision's ReplicaSet back up and the current one down, just like a normal rolling update. To go back further than one revision, find the one you want in the history and pass --to-revision:

kubectl rollout history deployment synergychat-web
kubectl rollout undo deployment synergychat-web --to-revision=2

rollout undo changes the deployment in the cluster, not the YAML file in your repo. If your file still has the bad config, your next kubectl apply will just break it all again.

Image Pull Errors

One of the most common causes of a bad deploy is a bad container image. When Kubernetes can't download an image, the pod gets stuck before its container ever starts:

  • ErrImagePull: The last attempt to pull the image failed.

  • ImagePullBackOff: Kubernetes is waiting a bit before trying again, and the wait gets longer each time.

The usual culprits are a typo in the image name, a tag that doesn't exist, or a private container registry that the cluster doesn't have credentials for. kubectl describe pod will tell you which: look for the Failed events at the bottom.

Assignment

A coworker deployed a new version of the SynergyChat website straight from their laptop, and now the new pods won't start. The good news is that the rolling update is stuck, so the old pods are still serving traffic.

Roll back the bad deploy.

Submit the shell checks.