mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-10 09:56:55 +00:00
34 lines
693 B
YAML
34 lines
693 B
YAML
|
apiVersion: kyverno.io/v1
|
||
|
kind: ClusterPolicy
|
||
|
metadata:
|
||
|
name: namespace-has-coordinator
|
||
|
spec:
|
||
|
validationFailureAction: Enforce
|
||
|
failurePolicy: Fail
|
||
|
rules:
|
||
|
- name: main-deployment-exists
|
||
|
context:
|
||
|
- name: deploymentCount
|
||
|
globalReference:
|
||
|
name: non-existent-reference
|
||
|
jmesPath: "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
|