Skip to content

Commit 6d15d0d

Browse files
authored
Merge pull request #26661 from adrianludwin/image-pull-policy
Better document default imagePullPolicy behaviour
2 parents f70878a + d2239f3 commit 6d15d0d

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

content/en/docs/concepts/configuration/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ The [imagePullPolicy](/docs/concepts/containers/images/#updating-images) and the
8181

8282
- `imagePullPolicy: Always`: every time the kubelet launches a container, the kubelet queries the container image registry to resolve the name to an image digest. If the kubelet has a container image with that exact digest cached locally, the kubelet uses its cached image; otherwise, the kubelet downloads (pulls) the image with the resolved digest, and uses that image to launch the container.
8383

84-
- `imagePullPolicy` is omitted and either the image tag is `:latest` or it is omitted: `Always` is applied.
84+
- `imagePullPolicy` is omitted and either the image tag is `:latest` or it is omitted: `imagePullPolicy` is automatically set to `Always`. Note that this will _not_ be updated to `IfNotPresent` if the tag changes value.
8585

86-
- `imagePullPolicy` is omitted and the image tag is present but not `:latest`: `IfNotPresent` is applied.
86+
- `imagePullPolicy` is omitted and the image tag is present but not `:latest`: `imagePullPolicy` is automatically set to `IfNotPresent`. Note that this will _not_ be updated to `Always` if the tag is later removed or changed to `:latest`.
8787

8888
- `imagePullPolicy: Never`: the image is assumed to exist locally. No attempt is made to pull the image.
8989

@@ -96,7 +96,7 @@ You should avoid using the `:latest` tag when deploying containers in production
9696
{{< /note >}}
9797

9898
{{< note >}}
99-
The caching semantics of the underlying image provider make even `imagePullPolicy: Always` efficient. With Docker, for example, if the image already exists, the pull attempt is fast because all image layers are cached and no image download is needed.
99+
The caching semantics of the underlying image provider make even `imagePullPolicy: Always` efficient, as long as the registry is reliably accessible. With Docker, for example, if the image already exists, the pull attempt is fast because all image layers are cached and no image download is needed.
100100
{{< /note >}}
101101

102102
## Using kubectl

content/en/docs/concepts/containers/images.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,32 @@ Instead, specify a meaningful tag such as `v1.42.0`.
4949

5050
## Updating images
5151

52-
The default pull policy is `IfNotPresent` which causes the
53-
{{< glossary_tooltip text="kubelet" term_id="kubelet" >}} to skip
54-
pulling an image if it already exists. If you would like to always force a pull,
55-
you can do one of the following:
52+
When you first create a {{< glossary_tooltip text="Deployment" term_id="deployment" >}},
53+
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}}, Pod, or other
54+
object that includes a Pod template, then by default the pull policy of all
55+
containers in that pod will be set to `IfNotPresent` if it is not explicitly
56+
specified. This policy causes the
57+
{{< glossary_tooltip text="kubelet" term_id="kubelet" >}} to skip pulling an
58+
image if it already exists.
59+
60+
If you would like to always force a pull, you can do one of the following:
5661

5762
- set the `imagePullPolicy` of the container to `Always`.
58-
- omit the `imagePullPolicy` and use `:latest` as the tag for the image to use.
63+
- omit the `imagePullPolicy` and use `:latest` as the tag for the image to use;
64+
Kubernetes will set the policy to `Always`.
5965
- omit the `imagePullPolicy` and the tag for the image to use.
6066
- enable the [AlwaysPullImages](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages) admission controller.
6167

68+
{{< note >}}
69+
The value of `imagePullPolicy` of the container is always set when the object is
70+
first _created_, and is not updated if the image's tag later changes.
71+
72+
For example, if you create a Deployment with an image whose tag is _not_
73+
`:latest`, and later update that Deployment's image to a `:latest` tag, the
74+
`imagePullPolicy` field will _not_ change to `Always`. You must manually change
75+
the pull policy of any object after its initial creation.
76+
{{< /note >}}
77+
6278
When `imagePullPolicy` is defined without a specific value, it is also set to `Always`.
6379

6480
## Multi-architecture images with image indexes

0 commit comments

Comments
 (0)