snippetdockerMinor
How to update pods if version hasn't changed?
Viewed 0 times
updateversionpodshasnhowchanged
Problem
During development we are continually building a Docker image with the same version (say 0.0.1-development) as there is no need to bump for each minor change. We do eventually bump when additional features are added.
We've discovered that
In the deployment we have
Is there a way we can achieve the desried behaviour of pulling down the image even if the version hasn't bumped, replacing the old containers each time?
We've discovered that
kubectl set image deployment/ourdeployment doesn't force the updated container to be pulled from Dockerhub and run if the version in the image hasn't changed.In the deployment we have
imagePullPolicy: Always but this doens't seem to have any effect.Is there a way we can achieve the desried behaviour of pulling down the image even if the version hasn't bumped, replacing the old containers each time?
Solution
The main problem here is, that from a Kubernetes point-of-view nothing has changed to your deployment. So nothing gets updated.
The best solution here would be, that you add something to your image tag, like the git short hash, for example. The your update will just work. Also you will make your deployments re-creatable, when you do it this way.
If you really want to keep it the way it is, you could add some other information to the deployment, that changes on each deployment, but is not used, like an annotation. But I would not recommend that, since I saw this leading to strange behavior with old pods no being shutdown.
On a side note: The
The best solution here would be, that you add something to your image tag, like the git short hash, for example. The your update will just work. Also you will make your deployments re-creatable, when you do it this way.
If you really want to keep it the way it is, you could add some other information to the deployment, that changes on each deployment, but is not used, like an annotation. But I would not recommend that, since I saw this leading to strange behavior with old pods no being shutdown.
On a side note: The
imagePullPolicy is just evaluated, when there is change to your deployment. So basically this flag says: If you do deploy something (e.g. bc there is a new deployment), no matter if you have the image already locally, reload it from the registry.Context
StackExchange DevOps Q#4655, answer score: 1
Revisions (0)
No revisions yet.