How do I update all my pods if the image is changed but the tag is the same

0 votes
I want to know the procedure for updating all the pods if the image is changed but the tag is the same? could anyone please help me with this?
Jul 12, 2019 in Kubernetes by Sam
• 6,260 points

2 answers to this question.

0 votes
  • Make sure your imagePullPolicy is set to Always(this is the default). 

  • That means when a pod is deleted, a new pod will ensure it has the current version of the image. 

  • Then refresh all your pods. 

  • The simplest way to refresh all your pods is to just delete them and they will be recreated with the latest image. 

  • This immediately destroys all your pods which will cause a service outage. 

  • Do this with kubectl delete pod -l <name>=<value> where name and value are the label selectors your deployment uses. 

  • A better way is to edit your deployment and modify the deployment pod spec to add or change any annotation. 

  • This will cause all your pods to be deleted and rescheduled, but this method will also obey your rollingUpdate strategy, meaning no downtime assuming your rollingUpdate strategy already behaves properly. 

  • Setting a timestamp or a version number is convenient, but any change to pod annotations will cause a rolling update. 

For a deployment named nginx, this can be done with:

kubectl patch deployment nginx -p "$PATCH"

It is considered bad practice to rely on the :latest docker image tag in your deployments, because using :latest there is no way to rollback or specify what version of your image to use. 

It is better to update the deployment with an exact version of the image and use --record so that you can use:

kubectl rollout undo deployment <deployment>  or other commands to manage rollouts.
answered Jul 12, 2019 by Sirajul
• 59,230 points
0 votes

since K8s 1.15

kubectl rollout restart 

do the job

so for a deployment

kubectl rollout restart deployment {mydeployment.yaml}

answered Jul 24, 2020 by Mathieu V

Related Questions In Kubernetes

0 votes
1 answer

How do I create a service account for my dashboard and get all the credentails

Run the following commands: This command will create ...READ MORE

answered Oct 8, 2018 in Kubernetes by Kalgi
• 52,360 points
0 votes
1 answer

How do we list all the pods which are using the same service?

Hi, If you want to manage your pods ...READ MORE

answered Oct 5, 2020 in Kubernetes by MD
• 95,440 points
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,570 views
0 votes
2 answers

How do I update all my pods if the image changed but the tag is the same? - Kubernetes

Make sure your imagePullPolicy is set to Always(this is the ...READ MORE

answered Aug 6, 2019 in Kubernetes by Sirajul
• 59,230 points
0 votes
1 answer

How can i get all the pods on a node?

You can use the following command to ...READ MORE

answered Jul 12, 2019 in Kubernetes by Sirajul
• 59,230 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP