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

0 votes
How do I update all my pods if the image changed but the tag is the same in kubernetes? Is it possible? If yes, how?
Jul 25 in Kubernetes by Ninja
16 views

2 answers to this question.

0 votes
Yes, this is possible. Refresh all your pods is to just delete them and they will be recreated with the latest image. This 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.
answered Jul 25 by Oliver
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:

PATCH='{"spec":{"template":{"metadata":{"annotations":{"timestamp":"'$(date)'"}}}}}'
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 Aug 6 by Sirajul
• 16,640 points

Related Questions In Kubernetes

0 votes
1 answer

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

Make sure your imagePullPolicy is set to ...READ MORE

answered Jul 12 in Kubernetes by Sirajul
• 16,640 points
37 views
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
• 39,150 points
212 views
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
• 16,640 points
19 views
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
• 16,640 points
30 views
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
1,568 views
+3 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How do I determine the status of a Deployment? - Kubernetes

Use kubectl get deployment <deployment>. If the ...READ MORE

answered Jul 25 in Kubernetes by Harsha
12 views