mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-10 18:06:55 +00:00
32 lines
667 B
YAML
Executable file
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
|