2023-09-17 22:24:26 +00:00
|
|
|
---
|
2020-11-18 22:58:32 +00:00
|
|
|
apiVersion: kyverno.io/v1
|
|
|
|
kind: ClusterPolicy
|
|
|
|
metadata:
|
|
|
|
annotations:
|
|
|
|
pod-policies.kyverno.io/autogen-controllers: DaemonSet,Deployment,StatefulSet
|
2023-09-17 22:24:26 +00:00
|
|
|
name: validate-probes
|
2020-11-18 22:58:32 +00:00
|
|
|
spec:
|
2023-09-17 22:24:26 +00:00
|
|
|
admission: true
|
2020-11-18 22:58:32 +00:00
|
|
|
background: false
|
|
|
|
rules:
|
2023-09-17 22:24:26 +00:00
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
2020-11-18 22:58:32 +00:00
|
|
|
kinds:
|
2023-09-17 22:24:26 +00:00
|
|
|
- Pod
|
|
|
|
name: validate-probes-c0
|
|
|
|
validate:
|
|
|
|
deny:
|
|
|
|
conditions:
|
|
|
|
- key: '{{ request.object.spec.containers[0].readinessProbe }}'
|
|
|
|
operator: Equals
|
|
|
|
value: '{{ request.object.spec.containers[0].livenessProbe }}'
|
|
|
|
message: Liveness and readiness probes cannot be the same.
|
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
2020-11-18 22:58:32 +00:00
|
|
|
kinds:
|
2023-09-17 22:24:26 +00:00
|
|
|
- Pod
|
|
|
|
name: validate-probes-c1
|
|
|
|
validate:
|
|
|
|
deny:
|
|
|
|
conditions:
|
|
|
|
- key: '{{ request.object.spec.containers[1].readinessProbe }}'
|
|
|
|
operator: Equals
|
|
|
|
value: '{{ request.object.spec.containers[1].livenessProbe }}'
|
|
|
|
message: Liveness and readiness probes cannot be the same.
|
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
2020-11-18 22:58:32 +00:00
|
|
|
kinds:
|
2023-09-17 22:24:26 +00:00
|
|
|
- Pod
|
|
|
|
name: validate-probes-c2
|
|
|
|
validate:
|
|
|
|
deny:
|
|
|
|
conditions:
|
|
|
|
- key: '{{ request.object.spec.containers[2].readinessProbe }}'
|
|
|
|
operator: Equals
|
|
|
|
value: '{{ request.object.spec.containers[2].livenessProbe }}'
|
|
|
|
message: Liveness and readiness probes cannot be the same.
|
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
2020-11-18 22:58:32 +00:00
|
|
|
kinds:
|
2023-09-17 22:24:26 +00:00
|
|
|
- Pod
|
|
|
|
name: validate-probes-c3
|
|
|
|
validate:
|
|
|
|
deny:
|
|
|
|
conditions:
|
|
|
|
- key: '{{ request.object.spec.containers[3].readinessProbe }}'
|
|
|
|
operator: Equals
|
|
|
|
value: '{{ request.object.spec.containers[3].livenessProbe }}'
|
|
|
|
message: Liveness and readiness probes cannot be the same.
|
|
|
|
validationFailureAction: Enforce
|