Description
With a mutable tag, imagePullPolicy governs whether a new container uses a cached image or checks the registry. Moving a tag does not update an already running container.
Potential impact
Replicas in the same Deployment can run different code if nodes have different images cached. Some may miss a patch.
Remediation
Set imagePullPolicy: Always when each start must check the tag. Verify registry access and test startup during an outage. For repeatable content, pin a verified digest and plan patch updates. IfNotPresent can be suitable with a pinned digest.
Examples
Both configurations run three replicas using library/nginx:1.20.0. Choose a verified, maintained image for deployment.
Before
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-with-image-pull-policy
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: library/nginx:1.20.0
imagePullPolicy: IfNotPresent
IfNotPresent can use the image already on the node without rechecking the tag.
After
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-with-image-pull-policy
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: library/nginx:1.20.0
imagePullPolicy: Always
Always resolves the tag’s digest at the registry on startup and reuses any matching cached layers.