Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm very new to kubernetes and all I want to do at this point is restart my cluster and have it run an updated dockerfile. I'm running kubernetes in google-cloud-platform by the way.

like image 403
hermancain Avatar asked Sep 17 '17 15:09

hermancain


People also ask

How do you update Docker image on Kubernetes deployment?

To update an existing deployment, you can use the kubectl edit command. Simply update the image attribute for your containers and save the Deployment. The deployment will automatically create new pods with the new image you specified, and terminate pods using the old image in a controlled fashion.


2 Answers

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

like image 160
JakubKnejzlik Avatar answered Oct 19 '22 16:10

JakubKnejzlik


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.

like image 23
mohan08p Avatar answered Oct 19 '22 18:10

mohan08p