How do I redeploy everything in kubernetes after updating a dockerfile?

kubectl from version 1.15 should contain kubectl rollout restart (according to this comment https://github.com/kubernetes/kubernetes/issues/33664#issuecomment-497242094)


You can use rolling update mechanism to update the service without outage which will update one pod at a time until the desired state match, and still your services are up and running. Of course we must have to update our containers inside the pod to protect our data and to get latest features out. Kubernetes makes it easy to roll out updates to your applications by modifying the deployments and managing them. It's major update time and we'll use easy way to tweak them.

Suppose you have front end, auth and back-end deployments and there is change into the auth or newer version, so you want to update auth deployment configuration file in which you could change its respective auth container image to newer version after building the new docker image and simply changing the image version in your .yaml file and apply as below

$ kubectl apply -f deployments/auth.yaml

Check that it succeed with the deployment describe command, you could see the rolling update strategy and figure out that right number of pods are always available. That uses the new replica set to ensure that we are running the latest version of auth container.

$ kubectl describe deployments auth

Once, the rolling update is complete, we can view the running pods for the auth service.

$ kubectl get pods

Check the time frame for which it is running. The new version of the auth pod has replaced the previous one. Once again check with the id of the new auth pod and verify. Updating deployment this way keeps us with a clean declarative approach to roll out changes to our application weather you have single or thousands of pods running.