Skip to content

Instantly share code, notes, and snippets.

@tommeramber
Created May 1, 2023 12:09
Show Gist options
  • Save tommeramber/d7a1e7a482a52798351316fb67ea7334 to your computer and use it in GitHub Desktop.
Save tommeramber/d7a1e7a482a52798351316fb67ea7334 to your computer and use it in GitHub Desktop.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-latest-tag
spec:
validationFailureAction: audit
background: true
rules:
- name: require-image-tag
match:
any:
- resources:
kinds:
- Pod
validate:
message: "An image tag is required."
pattern:
spec:
containers:
- image: "*:*"
- name: validate-image-tag
match:
any:
- resources:
kinds:
- Pod
validate:
message: "Using a mutable image tag e.g. 'latest' is not allowed."
pattern:
spec:
containers:
- image: "!*:latest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment