Skip to main content

☑️ Ensure each container has a configured readiness probe

Readiness probes allow Kubernetes to determine when a pod is ready to accept traffic. This ensures that client requests will not be routed to pods that are unable to process them.

Targeted objects by this rule (types of kind): Deployment / Pod / DaemonSet / StatefulSet / ReplicaSet / CronJob / Job

Complexity: hard (What does this mean?)

Policy as code identifier: CONTAINERS_MISSING_READINESSPROBE_KEY


This rule will fail

If a container doesn't have readinessProbe configured

spec:
containers:
- name: app
image: nginx:1.19.8

Rule output in the CLI

$ datree test *.yaml

>> File: failExample.yaml
❌ Ensure each container has a configured readiness probe [1 occurrence]
💡 Missing property object `readinessProbe` - add a properly configured readinessProbe to notify kubelet your Pods are ready for traffic

How to fix this failure

Configure a readiness probe with an HTTP request, TCP protocol or exec command (the least recommended option)

spec:
containers:
- name: app
image: nginx:1.19.8
readinessProbe:
httpGet:
path: /healthz
port: 8080
spec:
containers:
- name: app
image: nginx:1.19.8
readinessProbe:
tcpSocket:
port: 8080
spec:
containers:
- name: app
image: nginx:1.19.8
readinessProbe:
exec:
command:
- cat
- /tmp/healthy

Read more