What is the difference between liveness and readiness probes in K8s?
Kubernetes uses probes to determine the health of a container, but liveness and readiness probes serve fundamentally different purposes and trigger different control-plane actions.
A **liveness probe** answers the question: "Is this container still alive?" If the probe fails, kubelet kills the container and restarts it according to the pod's `restartPolicy`. Use liveness probes to recover from deadlocks or infinite loops — states where the process is running but making no progress. A classic example is a JVM that has deadlocked: the process is up, but no requests complete. Without a liveness probe the pod would stay in a broken state forever.
A **readiness probe** answers the question: "Is this container ready to serve traffic?" If the probe fails, the pod's IP is removed from the Endpoints object of any matching Service, so the load balancer stops routing new connections to it. The container is *not* restarted. This is the right tool for a pod that is temporarily overwhelmed, waiting for a dependency (database, cache), or performing a warm-up operation like loading a large ML model into memory.
Both probes support three mechanisms: `httpGet` (checks for a 2xx/3xx HTTP response), `tcpSocket` (checks that a port accepts connections), and `exec` (runs a command inside the container and checks the exit code). Key configuration fields include `initialDelaySeconds` (grace period before the first check), `periodSeconds` (how often to check), `failureThreshold` (consecutive failures before action), and `successThreshold` (consecutive successes to recover readiness).
A common production pattern is to run both together: the readiness probe uses a lightweight `/healthz` endpoint that also validates upstream dependencies, while the liveness probe hits a simpler `/livez` endpoint that only confirms the process is responsive. This prevents a cascade where a failing dependency causes a restart loop (liveness) when the correct behavior is to shed traffic (readiness).
Missing a readiness probe is one of the most frequent causes of failed rolling deployments — new pods receive traffic before they are ready, spiking error rates.
| Aspect | Liveness Probe | Readiness Probe |
|---|---|---|
| Purpose | Is the container alive? | Is the container ready for traffic? |
| Failure action | Container is killed and restarted | Pod removed from Service Endpoints |
| Restart triggered? | Yes | No |
| Typical use case | Deadlock, infinite loop recovery | Warm-up, dependency wait, overload shedding |
| Missing probe consequence | Broken pod never recovers | Traffic hits unready pods during rollout |
| Shared mechanisms | httpGet, tcpSocket, exec | httpGet, tcpSocket, exec |
Correctly states what each probe does and the restart vs. traffic-shedding distinction. May lack detail on configuration fields or production patterns.
Explains the failure actions precisely (Endpoints removal vs. restart), names all three probe mechanisms, provides concrete use cases for each, and notes the risk of using liveness where readiness is appropriate.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment