Skip to main content

⏪ Rollback

A rollback undoes an update that went wrong, returning the Deployment to a previous version. It is Kubernetes' "undo", and it works in seconds.

info

Rollbacks are done with kubectl. The Nuvion Panel does not have this feature.


🚀 Before you start​

  • Have cluster access configured (see Cluster Access).
  • Have the web-deploy Deployment with at least one update made (see Rollout).

🚀 1. See the available versions​

kubectl rollout history deployment/web-deploy

Each line is a revision. Note the number of the version that worked.

🚀 2. Simulate an update with a problem​

Update to an image that does not exist:

kubectl set image deployment/web-deploy nginx=nginx:versao-que-nao-existe
kubectl get pods -l app=web-deploy

The new pods stay in ErrImagePull or ImagePullBackOff, but the old pods keep running and serving, because Kubernetes does not remove them until the new ones are ready.

🚀 3. Undo the last update​

kubectl rollout undo deployment/web-deploy
kubectl rollout status deployment/web-deploy

The Deployment returns to the previous revision (in this example, nginx:1.27).

🚀 4. Return to a specific revision​

kubectl rollout history deployment/web-deploy --revision=1
kubectl rollout undo deployment/web-deploy --to-revision=1

The first command shows what revision 1 had (including the image). The second returns to it.

🚀 5. Confirm​

kubectl get deployment web-deploy -o jsonpath='{.spec.template.spec.containers[0].image}'
kubectl get pods -l app=web-deploy

The first shows the current image. All pods should be Running.

warning

Rollback undoes what is in the pod template (image, variables, resources). It does not undo the number of replicas, nor the content of a ConfigMap or Secret.

✅ How to know it worked​

kubectl rollout status ends with successfully rolled out, and the image shown in step 5 is the version that worked.

❗ Common problems​

SymptomCauseSolution
no rollout history foundThe Deployment was never updatedMake an update first (Rollout)
unable to find specified revisionThe revision does not exist or was already removedSee the available ones in kubectl rollout history
The rollback did not fix itThe problem is elsewhere (ConfigMap, Secret, database)See Logs and Events

🧹 Cleanup​

If you will not use the Deployment on the next pages:

kubectl delete deployment web-deploy

➡️ Next step: Terminal

🧠 Questions?​

Talk to our SaveinCloud technical support team!