1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-09 01:16:55 +00:00
kyverno/test/conformance/kuttl/validate/e2e/trusted-images/policy.yaml
Charles-Edouard Brétéché 8f84d222ef
chore: use Enforce instead of enforce in kuttl tests (#6763)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-04-03 13:36:30 +00:00

35 lines
951 B
YAML

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-trustable-images
spec:
validationFailureAction: Enforce
rules:
- name: only-allow-trusted-images
match:
any:
- resources:
kinds:
- Pod
preconditions:
- key: "{{request.operation}}"
operator: NotEquals
value: DELETE
validate:
message: "images with root user are not allowed"
foreach:
- list: "request.object.spec.containers"
context:
- name: imageData
imageRegistry:
reference: "{{ element.image }}"
jmesPath: "{user: configData.config.User || '', registry: registry}"
deny:
conditions:
all:
- key: "{{ imageData.user }}"
operator: Equals
value: ""
- key: "{{ imageData.registry }}"
operator: NotEquals
value: "ghcr.io"