Video in progress
What is the difference between liveness and readiness probes in Kubernetes?
Readiness answers "can this pod receive traffic?": if it fails, the pod is taken out of the Service but not killed. Liveness checks "is the process alive?": if it fails, the kubelet restarts the container.
📖 Answer
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }
periodSeconds: 5
failureThreshold: 3
livenessProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 10
failureThreshold: 3
If Spring Boot detects it is running inside Kubernetes, it turns on these two groups itself (you can enable them anywhere with management.endpoint.health.probes.enabled=true).
Which one fails when:
- the app is starting up and warming its cache: readiness is
DOWN, no traffic arrives, and no restart happens; - a deadlock happened and the threads are stuck: liveness fails, and a restart helps.
A common mistake: adding a DB check to liveness. The database goes down for a minute, all pods restart at the same time, and when the database comes back they are still starting up. A restart does not fix a DB problem, so keep external dependencies out of liveness.
Sign up to mark studied questions and save your progress.