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:

  Normal   Pulling                6m (x4 over 7m)   kubelet, minikube  pulling image "gcr.io/google-samples/kubernetes-bootcamp:v10"
  Warning  Failed                 6m (x4 over 7m)   kubelet, minikube  Failed to pull image "gcr.io/google-samples/kubernetes-bootcamp:v10": rpc error: code = Unknown desc = unauthorized: authentication required
  Warning  Failed                 6m (x4 over 7m)   kubelet, minikube  Error: ErrImagePull
  Normal   BackOff                5m (x6 over 7m)   kubelet, minikube  Back-off pulling image "gcr.io/google-samples/kubernetes-bootcamp:v10"
  Warning  Failed                 2m (x20 over 7m)  kubelet, minikube  Error: ImagePullBackOff

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 *