Liveness, readiness and startup probes
Tell Kubernetes when your container can take traffic, when it must be restarted, and how long to wait at boot.
Open this lesson in the learning hubKey points
- readiness controls traffic. Fail it and the pod leaves the Service endpoints, but it is not restarted.
- liveness controls restarts. Fail it and the kubelet kills the container. Keep this check dumb and local.
- Never touch the database from a liveness probe. One slow query then restarts every pod at once.
- startup probes cover slow boots. While one runs, the other two are paused, which beats a huge
initialDelaySeconds. - Spring Boot serves
/actuator/health/livenessand/actuator/health/readiness, enabled automatically when it detects Kubernetes.
Example
containers:
- name: app
image: ghcr.io/acme/web:1.4.2
ports:
- containerPort: 8080
startupProbe: # up to 30 x 5s = 150s to boot
httpGet:
path: /actuator/health/liveness
port: 8080
failureThreshold: 30
periodSeconds: 5
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
periodSeconds: 5
failureThreshold: 3
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
periodSeconds: 10
failureThreshold: 3
Readiness protects your users. Liveness protects you from a wedged process.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Kubernetes course, and every lesson in it is listed on the Kubernetes contents page.