AlwaysPullImages Admission Plugin
Required knowledge for the CKS certification.
The AlwaysPullImages admission controller is a mutating and validating admission plugin that modifies every new Pod to force its image pull policy to Always. It addresses a specific authorization gap in multi-tenant clusters: without this plugin, any pod that is scheduled onto a node where an image is already cached can use that image by knowing its name, without any credential check against the registry.
The Security Problem
By default, Kubernetes respects the imagePullPolicy set on each container. When set to IfNotPresent or when unset on a tagged image, the kubelet uses a locally cached layer if one exists. This creates an authorization gap in shared clusters:
Issue: Once a private image has been pulled to a node — by any authorized workload — any other pod scheduled to that node can reference the same image by name and start a container from it, with no check that the requesting pod's owner is authorized to pull the image from the registry.
Fix: Enable the AlwaysPullImages admission controller so that every new pod's image pull policy is forced to Always, requiring valid registry credentials on every container start.
This matters most in multi-tenant clusters where:
- Different teams share nodes
- Private images contain proprietary code, credentials, or sensitive data
- Registry access control (such as repository-scoped permissions) is the intended authorization boundary for image access
What the Plugin Does
AlwaysPullImages is both a mutating and a validating admission controller:
- Mutating pass: Sets
imagePullPolicy: Alwayson every container in every new Pod, overriding whatever value was specified in the manifest. - Validating pass: Ensures the policy has been applied before the pod is admitted.
The result is that the registry is consulted on every container start. If the pod's service account or image pull secret does not have permission to pull the image, the kubelet receives a registry authentication failure and the container does not start.
Enabling the Plugin
Add AlwaysPullImages to the --enable-admission-plugins flag on the API server:
kube-apiserver \
--enable-admission-plugins=...,AlwaysPullImages,...
On kubeadm clusters, edit the static pod manifest at /etc/kubernetes/manifests/kube-apiserver.yaml and add AlwaysPullImages to the existing --enable-admission-plugins value.
Verify the plugin is active
kubectl get pod kube-apiserver-$(hostname) -n kube-system -o yaml \
| grep enable-admission-plugins
The output must include AlwaysPullImages.
Verify behavior on a new pod
Deploy a pod with an explicit imagePullPolicy: IfNotPresent and inspect the admitted spec:
kubectl run test-pull \
--image=nginx:stable \
--image-pull-policy=IfNotPresent \
--dry-run=server \
-o jsonpath='{.spec.containers[0].imagePullPolicy}'
When AlwaysPullImages is enabled, the returned value is Always regardless of the requested policy.
Operational Considerations
Image pull credentials are required at every start
Because every container start triggers an image pull, all pods must have access to valid registry credentials for every image they use. For private registries this means:
- An
imagePullSecretreferencing a valid registry credential must be present on every pod, or - The pod's service account must have an
imagePullSecretattached.
A pod using a public image is unaffected beyond the latency of a registry manifest check on each startup.
Interaction with node image cache
Enabling AlwaysPullImages does not remove the node's local image cache. Images are still cached after the first pull. The plugin ensures that the registry is contacted to verify credentials and that the digest matches, but if the registry returns the cached manifest, the kubelet may skip re-downloading image layers. The credential check still runs regardless.
Registries must be reachable at pod startup
If the registry is unreachable when a pod starts — due to a network partition, rate limiting, or registry downtime — the pull fails and the container does not start. Plan for registry availability in your reliability model when enabling this plugin cluster-wide.
Interaction with other admission plugins
AlwaysPullImages can be combined with the ValidatingAdmissionPolicy or OPA Gatekeeper to enforce additional image source restrictions — for example, requiring images to come from a specific registry prefix — while AlwaysPullImages ensures that those approved-registry images are always re-validated at the registry on startup.
Relationship to Supply Chain Controls
AlwaysPullImages enforces an authentication check at the registry layer but does not verify image content integrity. It answers the question "is this identity authorized to pull this image?" rather than "is this image what we signed?". Use it together with:
- Cosign image signing to verify that only signed images are admitted.
- Service account tokens for image pulls to avoid long-lived
imagePullSecretsand use short-lived projected tokens instead.
References
This article is based on information from the following official sources:
- Admission Controllers Reference — AlwaysPullImages - Kubernetes