Kubernetes: update a deployed application and rollback

To update a deployed application use set image.

E.g. successful

kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2

Check with:

kubectl get deployments

should show DESIRED, CURRENT, UP-TO-DATE in sync.


However, here’s an example of a failure

kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=gcr.io/google-samples/kubernetes-bootcamp:v10


kubectl get deployments

shows DESIRED, CURRENT, UP-TO-DATE  are out of sync.

E.g. kubectl get pods

shows 2 with a Status of ImagePullBackOff

and kubectl describe pods

shows in Events:

To undo the deployment, use:

kubectl rollout undo deployments/kubernetes-bootcamp

This reverts to the previous known state. i.e. v2and

kubectl get deployments shows the pods in sync.


From this great tutorial: https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-interactive/

Leave a Reply

Your email address will not be published. Required fields are marked *