1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 15:37:19 +00:00
kyverno/samples/RequirePodProbes.md

35 lines
939 B
Markdown
Raw Normal View History

2019-10-23 14:06:03 -07:00
# Require `livenessProbe` and `readinessProbe`
2019-10-23 15:36:37 -07:00
For each pod, a `livenessProbe` is carried out by the kubelet to determine if containers are running and when to restart the pod. A `readinessProbe` is used by services and deployments to determine if the pod is ready to recieve network traffic.
2019-10-23 14:06:03 -07:00
Both liveness and readiness probes need to be configured to manage the pod lifecycle during restarts and upgrades.
## Policy YAML
[require_probes.yaml](best_practices/require_probes.yaml)
````yaml
apiVersion: kyverno.io/v1alpha1
kind: ClusterPolicy
metadata:
name: validate-probes
spec:
rules:
- name: check-probes
match:
resources:
kinds:
- Pod
validate:
message: "Liveness and readiness probes are required"
pattern:
spec:
containers:
- livenessProbe:
periodSeconds: ">0"
readinessProbe:
periodSeconds: ">0"
````