Is there a way to make kubectl apply restart deployments whose image tag has not changed? Is there a way to make kubectl apply restart deployments whose image tag has not changed? kubernetes kubernetes

Is there a way to make kubectl apply restart deployments whose image tag has not changed?


I'm not entirely sure I understood your question but that may very well be my reading comprehension :)In any case here's a few thoughts that popped up while reading this (again not sure what you're trying to accomplish)

Option 1: maybe what you're looking for is to scale down and back up, i.e. scale your deployment to say 0 and then back up, given you're using configmap and maybe you only want to update that, the command would be kubectl scale --replicas=0 -f foo.yaml and then back to whatever

Option 2: if you want to apply the deployment and not kill any pods for example, you would use the cascade=false (google it)

Option 3: lookup the rollout option to manage deployments, not sure if it works on services though

Finally, and that's only me talking, share some more details like which version of k8s are you using? maybe provide an actual use case example to better describe the issue.


Kubernetes, only triggers a deployment when something has changed, if you have image pull policy to always you can delete your pods to get the new image, if you want kube to handle the deployment you can update the kubernetes yaml file to container a constantly changing metadata field (I use seconds since epoch) which will trigger a change. Ideally you should be tagging your images with unique tags from your CI/CD pipeline with the commit reference they have been built from. this gets around this issue and allows you to take full advantage of the kubernetes rollback feature.