mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-10 09:56:55 +00:00
* feat(validation-webhook): validate global context reference Signed-off-by: Khaled Emara <khaled.emara@nirmata.com> * fix(validation-webhook): global reference name Signed-off-by: Khaled Emara <khaled.emara@nirmata.com> * test(globalcontext): fix tests after valdiation Signed-off-by: Khaled Emara <khaled.emara@nirmata.com> * fix(policycache): dont add NotReady Policies Signed-off-by: Khaled Emara <khaled.emara@nirmata.com> * chore(globalcontext): rename e2e tests Signed-off-by: Khaled Emara <khaled.emara@nirmata.com> * chore(globalcontext): add entry errors Signed-off-by: Khaled Emara <khaled.emara@nirmata.com> * test(globalcontext): fix chainsaw test Signed-off-by: Khaled Emara <khaled.emara@nirmata.com> --------- Signed-off-by: Khaled Emara <khaled.emara@nirmata.com>
33 lines
690 B
YAML
Executable file
33 lines
690 B
YAML
Executable file
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: deployments
|
|
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
|