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 in Kubernetes by Sam
• 1,070 points

1 answer 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 by Sirajul
• 5,960 points

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
• 37,320 points
0 votes
1 answer
0 votes
1 answer

What all packages do i need to install to use kubernetes on my machine?

Install below packages on all of your ...READ MORE

answered Jul 11 in Kubernetes by Sirajul
• 5,960 points
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17 in Others by anonymous
+3 votes
1 answer
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 in Kubernetes by Sirajul
• 5,960 points