1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-10 01:46:55 +00:00
kyverno/test/conformance/chainsaw/globalcontext/validate-reference/clusterpolicy.yaml
2024-03-14 16:12:39 +00:00

32 lines
667 B
YAML
Executable file

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: cpol-gctx-validate-reference
spec:
validationFailureAction: Enforce
failurePolicy: Fail
rules:
- name: main-deployment-exists
context:
- name: deploymentCount
globalReference:
jmesPath: "items | length(@)"
match:
all:
- resources:
kinds:
- Pod
preconditions:
all:
- key: '{{ request.operation }}'
operator: AnyIn
value:
- CREATE
- UPDATE
validate:
deny:
conditions:
any:
- key: "{{ deploymentCount }}"
operator: Equal
value: 0