mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-09 17:37:12 +00:00
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com> Co-authored-by: Jim Bugwadia <jim@nirmata.com>
32 lines
661 B
YAML
Executable file
32 lines
661 B
YAML
Executable file
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: cpol-gctx-validate-reference
|
|
spec:
|
|
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:
|
|
failureAction: Enforce
|
|
deny:
|
|
conditions:
|
|
any:
|
|
- key: "{{ deploymentCount }}"
|
|
operator: Equal
|
|
value: 0
|