2

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 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?

1

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 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.

| improve this answer | |
  • That makes sense and I think adding the short git hash is a good solution to the problem. I've accepted your answer. – Caledonia91 Aug 1 '18 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.