Description
AlwaysPullImages sets the pull policy of new Pods to Always. Starting a container then requires a registry check, but matching cached layers can be reused.
Potential impact
Depending on the node configuration, a workload on a shared node may reuse another user’s cached private image. Checking registry authorization reduces that risk.
Remediation
Where needed, add AlwaysPullImages to the API server’s --enable-admission-plugins list. Supply credentials to workloads that need authenticated image pulls. Check the policy on a new Pod and test startup during a registry outage. Verify image approval, digests, signatures and vulnerabilities separately.
Examples
These excerpts show only API server arguments. Match the image to the running cluster version and supply the other control-plane settings. The plugin needs no separate admission configuration file.
Before
apiVersion: v1
kind: Pod
metadata:
name: command-demo
spec:
containers:
- name: command-demo-container
image: registry.k8s.io/kube-apiserver:v1.34.0
command: ["kube-apiserver"]
args: ["--disable-admission-plugins=AlwaysPullImages"]
After
apiVersion: v1
kind: Pod
metadata:
name: command-demo
spec:
containers:
- name: command-demo-container
image: registry.k8s.io/kube-apiserver:v1.34.0
command: ["kube-apiserver"]
args:
["--enable-admission-plugins=AlwaysPullImages"]
The first configuration leaves the pull decision to each Pod’s effective policy. The second enforces Always on new Pods.