Skip to main content

☑️ Ensure each container probe has a configured frequency

Probes have a number of fields that are used to control the behavior of liveness, readiness and startup checks. Though these fields have default values, we suggest to explicitly set them with your desired values.
One reason to do so is to prevent cases where unknown default behavior is used. For example, a defect was found in one of these fields causing it to be ignored, and was corrected in Kubernetes v1.20.

The field periodSeconds defines how often (in seconds) the kubelet should perform a liveness probe. It has a default value of 10 seconds, and a minimum value of 1 second.

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

Complexity: medium (What does this mean?)

Policy as code identifier: CONTAINERS_INCORRECT_PERIODSECONDS_VALUE


This rule will fail

If a container has a livenessProbe, readinessProbe and/or startupProbe configured, but the field periodSeconds is not configured or has a value smaller than 1

spec:
containers:
- name: myContainer
readinessProbe:
periodSeconds: 0
spec:
containers:
- name: myContainer
readinessProbe:
timeoutSeconds: 0

Rule output in the CLI

$ datree test *.yaml

>> File: failExample.yaml
❌ Ensure each container probe has a configured frequency [1 occurrence]
💡 Incorrect value for key `periodSeconds` - set explicitly to control how often a probe is performed (min 1)

How to fix this failure

Each container probe should have a configured periodSeconds property with a minimum value of 1

spec:
containers:
- name: myContainer
readinessProbe:
periodSeconds: 2

Read more