Set imagePullPolicy
Sample policy that sets imagePullPolicy to “Always” when the “latest” tag is used.
Policy Definition
/other/imagepullpolicy-always.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: imagepullpolicy-always
annotations:
policies.kyverno.io/title: Set imagePullPolicy
policies.kyverno.io/category: Sample
policies.kyverno.io/description: >-
Sample policy that sets imagePullPolicy to "Always" when the "latest" tag is used.
spec:
validationFailureAction: audit
background: false
rules:
- name: imagepullpolicy-always
match:
resources:
kinds:
- Pod
validate:
message: >-
The imagePullPolicy must be set to `Always` when the tag `latest` is used.
pattern:
spec:
containers:
- (image): "*:latest | !*:*"
imagePullPolicy: "Always"
Last modified January 2, 2021: fix title & sort and regen policies (fa7e171)