问题
I have a Kubernetes deployment which uses image: test:latest
(not real image name but it's the latest tag).
This image is on docker hub. I have just pushed a new version of test:latest
to dockerhub. I was expecting a new deployment of my pod in Kubernetes but nothing happends.
I've created my deployment like this:
kubectl run sample-app --image=`test:latest` --namespace=sample-app --image-pull-policy Always
Why isn't there a new deployment triggered after the push of a new image?
回答1:
Kubernetes is not watching for a new version of the image. The image pull policy specifies how to acquire the image to run the container. Always
means it will try to pull a new version each time it's starting a container. To see the update you'd need to delete the Pod (not the Deployment) - the newly created Pod will run the new image.
There is no direct way to have Kubernetes automatically update running containers with new images. This would be part of a continuous delivery system (perhaps using kubectl set image
with the new sha256sum or an image tag - but not latest
).
来源:https://stackoverflow.com/questions/45905999/kubernetes-image-pull-policy-always-does-not-work