Video in progress
What is the difference between liveness and readiness probes in Kubernetes?
Liveness answers "is the process alive, does it need a restart?"; if it fails, the pod is restarted. Readiness asks "can it accept traffic?"; if it fails, the pod is only removed from the Service, not killed.
📖 Answer
The difference is in the outcome:
| Liveness fail | Readiness fail | |
|---|---|---|
| What Kubernetes does | restarts the container | routes traffic to other pods |
| When you need it | a deadlock, the application is "frozen" | startup, cache warm-up, temporary load |
If Spring Boot detects it is running inside Kubernetes, it enables both groups automatically: /actuator/health/liveness and /actuator/health/readiness. In other environments, by hand:
management:
endpoint:
health:
probes:
enabled: true
In the Deployment:
livenessProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 10
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }
periodSeconds: 5
A common mistake is adding a database check to liveness. The database doesn't respond for 30 seconds and all the pods restart at once, even though they were healthy and the problem was in the database. External dependencies should at most be in readiness, while liveness checks only the application's own state.
For slow-starting applications there is also a startupProbe: liveness isn't checked until it passes.
Sign up to mark studied questions and save your progress.