Updating an application on Kubernetes is always done with rolling updates, allowing us to update a deployment with zero downtime. So new (additional) Pods get scheduled on our Node and Kubernetes waits for them to start before removing the old ones. So lets get started and update our app.
Updating our deployment basically means: Updating the image used by the container. Luckily, we already have a new image available: “vtrhh/hello-world-app:v2”. Lets update our deployments to use that image via
kubectl set image deployments/hello-world hello-world-app=vtrhh/hello-world-app:v2
⚠️ If you are a linux user, please use the following command (and another image) instead:
kubectl set image deployments/hello-world hello-world-app=vtrhh/hello-world-app:v2-amd64
To check what is happening with our pods, lets list them via
kubectl get pods
As you can see, there were two new Pods started and the old Pods are terminating. We can also check the status of our update via
kubectl rollout status deployment/hello-world
When our deployment is successfully rolled out, let’s check if we can see any updates in the browser. You should see a slight change of our app :)
We successfully updates our deployment, but what if we realised we would need the old version back? No worries, we can also roll-back our deployment via
kubectl rollout undo deployments/hello-world
We can again check our pods as well as our browser - and the app look like in the beginning.