What's the benefit of not using ImagePullPolicy set to Always?

3/8/2019

In the Kubernetes documentation it mentions that the caching semantic of using ImagePullPolicy: Always makes the ImagePullPolicy quite efficient. What reasons would I want to choose a different ImagePullPolicy?

-- chris.mclennon
kubernetes

2 Answers

3/8/2019

It heavily depends on your versioning/tagging strategy.

When new replicas of your application are created (because your app has scaled up, or a pod has died and it's been replaced by a new pod), if you use ImagePullPolicy: Always and you have pushed a different version of your application using the same tag (like people do when using latest), the new created replicas might run a totally different version of the application than the rest of the replicas, leading to an inconsistent behavior.

You also may want to use a different value than Always when on a development environment like minikube.

-- Jose Armesto
Source: StackOverflow

3/9/2019

There isn't much of a disadvantage to ImagePullPolicy: Always, but having the control means that:

  • if you have an underlying image provider that doesn't provide caching (ie you're not using Docker), you have control to make sure that it's not called every time the kubelet wants the image
  • even with Docker caching, it's still going to be slightly faster to not attempt to pull the image every time. If you know that you never re-use a tag (which is recommended) or you're explicitly specifying the image digest then there's no benefit to ImagePullPolicy: Always
  • if you have an installation where you're pulling the image onto the node using a separate mechanism, you may want it to not attempt an automatic fetch if something goes wrong and the image doesn't exist.

Note that in fiunchinho's answer it mentions that you can use it to keep various replicas of an application in sync. This would be dangerous as images as pulled per node, and so you could end up with different versions of the application running on different nodes.

-- user1458424
Source: StackOverflow