Difficulty: Intermediate
Explain liveness, readiness and startup probes in Kubernetes. What does each one do when it fails, and how do you configure them safely?
Probes are health checks the kubelet runs against your containers. A liveness probe failing makes the kubelet restart the container; a readiness probe failing removes the Pod from Service endpoints so it stops receiving traffic, without restarting it; and a startup probe holds off the other two until a slow-starting app has finished booting.
| Probe | Question it asks | Action on failure | Typical check |
|---|---|---|---|
| Liveness | Is the process stuck or deadlocked? | Restart the container | Lightweight /livez endpoint |
| Readiness | Can it serve traffic right now? | Remove from EndpointSlices | /readyz that checks warm-up and critical deps |
| Startup | Has it finished starting? | Restart if it never succeeds | Same endpoint as liveness, with a long budget |
Readiness keeps running for the whole life of the Pod, so a Pod can go not-ready under load or during a dependency outage and come back on its own.
httpGet (2xx or 3xx is success), tcpSocket, exec (exit code 0) and grpc (GA since v1.27).periodSeconds (default 10), timeoutSeconds (default 1), failureThreshold (default 3), successThreshold (default 1, must be 1 for liveness and startup), initialDelaySeconds (default 0).failureThreshold × periodSeconds. For a Java app that needs up to 2 minutes, use failureThreshold: 24 with periodSeconds: 5 instead of a large initialDelaySeconds on the liveness probe.During a rolling update, Kubernetes only counts a new Pod as available once its readiness probe passes. Without one, traffic goes to Pods that are still loading caches or opening DB pools, causing 502s during every deploy. A good readiness probe is the main ingredient of zero-downtime deployments.
CrashLoopBackOff.containers:
- name: orders
image: ghcr.io/acme/orders:3.2.0
ports:
- containerPort: 8080
startupProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 5
failureThreshold: 24 # up to 120s to boot
livenessProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3 # restart after ~30s of failure
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }
periodSeconds: 5
failureThreshold: 2 # leave rotation quickly
Spring Boot Actuator exposes separate liveness and readiness groups. Liveness only checks the app itself, while readiness can include warm-up state.
kubectl describe pod orders-6c9f7-abcde | grep -A5 -i "probe\|Events"
kubectl get pods -w # watch READY column flip and RESTARTS increase
Probe failures appear as Unhealthy events in describe output, with the HTTP status or error.
Liveness Probe, Readiness Probe, Startup Probe, Self-healing, EndpointSlice