Kubernetes: --image-pull-policy always does not work

8/27/2017

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?

-- DenCowboy
dockerhub
kubernetes

2 Answers

2/4/2020

If you are working with yml files, executing deployment with

kubectl apply -f myfile.yml

and

imagePullPolicy: Always

on your file, k8s will not pull a new image. You will first need to delete the pod, and the K8s deployment will automatically pull the image.

-- yaach
Source: StackOverflow

8/27/2017

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

-- Janos Lenart
Source: StackOverflow