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, 2019 in Kubernetes by Ninja
3,065 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, 2019 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, 2019 by Sirajul
• 59,230 points

Related Questions In Kubernetes

0 votes
2 answers

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

since K8s 1.15 kubectl rollout restart do the ...READ MORE

answered Jul 24, 2020 in Kubernetes by Mathieu V
6,762 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
• 52,360 points
1,458 views
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
376 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, 2019 in Kubernetes by Sirajul
• 59,230 points
652 views
+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
14,523 views
+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 5,976 views
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, 2019 in Kubernetes by Harsha
470 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP