What is the difference between liveness, readiness and startup probes in Kubernetes?
A liveness probe asks "is this container stuck?" and Kubernetes restarts it if the probe keeps failing. A readiness probe asks "can it take traffic right now?" and a failing Pod is removed from Service load balancing without a restart. A startup probe gives slow-starting apps time to boot before the other probes begin.
Explain it simply
Think of a cashier at a busy railway reservation counter.
- Readiness: the cashier has stepped away to count cash, so the "counter closed" board goes up. Nobody is fired; people are just sent to other counters until the board comes down.
- Liveness: the cashier has fallen asleep and no amount of knocking wakes them. The supervisor replaces them with a fresh person.
- Startup: a new cashier needs ten minutes to log in and set up. The supervisor does not start knocking until setup is done.
Readiness controls traffic. Liveness controls restarts. Startup protects slow boots.
Example
apiVersion: v1
kind: Pod
metadata:
name: api
spec:
containers:
- name: api
image: example/api:1.4.0
ports:
- containerPort: 8080
startupProbe:
httpGet:
path: /healthz
port: 8080
periodSeconds: 5
failureThreshold: 24 # up to 120 seconds to start
livenessProbe:
httpGet:
path: /healthz
port: 8080
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3 # restart after about 30 seconds of failures
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5
failureThreshold: 2In a real app these probes go inside a Deployment's Pod template. /healthz returns 200 if the process is alive and responsive. /ready returns 200 only when the app has finished loading config and warming caches and can serve requests.
How it works
The kubelet on each node runs the probes. A probe can be an HTTP GET (success is a status from 200 to 399), a TCP connection check, a command run inside the container (success is exit code 0), or a gRPC health check.
- Liveness fails
failureThresholdtimes in a row: the kubelet kills the container and restarts it according to the Pod's restart policy. Repeated failures show up asCrashLoopBackOffwith growing delays. - Readiness fails: the Pod is marked not ready and removed from the Service's endpoints, so no new traffic is sent to it. The container keeps running, and when the probe passes again it is added back. Readiness is checked for the whole life of the Pod, not only at startup.
- Startup probe: while it is running, liveness and readiness are disabled. Once it succeeds, the others take over. If it never succeeds within its threshold, the container is restarted.
Readiness also gates rolling updates: a Deployment counts a new Pod as available only after it is ready, so a broken version stalls instead of replacing all the healthy Pods.
Real-world use
A Java service that takes 90 seconds to load gets a startup probe so liveness does not kill it at second 30, which would cause an endless restart loop. During a traffic spike, an overloaded Pod can fail readiness briefly to shed load while the other replicas keep serving. A Pod with a deadlocked thread pool still has a running process, but the liveness endpoint times out and Kubernetes restarts it automatically at night without anyone being paged.
Common mistakes
- Checking the database in the liveness probe. If the database goes down, every Pod fails liveness and restarts together, which makes the outage worse and does nothing to fix the database. Liveness should check only the process itself.
- Using the same endpoint and settings for liveness and readiness without thinking about what each failure should do.
- Aggressive timeouts. A one-second timeout under garbage-collection pauses or heavy load causes needless restarts.
- No readiness probe, so traffic hits Pods before they can serve and users see errors during every deploy.
- Using a huge
initialDelaySecondson liveness instead of a startup probe.
What to say in the interview
"All three are health checks run by the kubelet, but they trigger different actions. Liveness answers whether the container is healthy enough to keep; if it fails repeatedly, the container is restarted. Readiness answers whether the Pod should receive traffic; if it fails, the Pod is taken out of the Service endpoints but not restarted, and it rejoins when it passes. A startup probe holds off the other two until a slow app has booted. I keep liveness shallow, only checking the process, so a dependency outage does not cause a restart storm, and I use readiness for warming up and temporary overload."
Follow-up questions
- What happens during a rolling update if the new Pods never become ready?
- Should a readiness probe check downstream dependencies?
- What does CrashLoopBackOff mean and how do you debug it?
- How do you shut a Pod down gracefully so in-flight requests are not dropped?
Go deeper
Read these once the basics above feel easy.
Whether readiness should check dependencies is a judgement call. If every Pod depends on the same database, failing readiness on all of them just leaves the Service with no endpoints, so callers get connection errors instead of a clear 503. Many teams keep readiness focused on the Pod's own ability to serve, and handle dependency failures in code with timeouts, retries and circuit breakers.
Graceful shutdown ties in with readiness. When a Pod is deleted, Kubernetes removes it from endpoints and sends SIGTERM at roughly the same time, and endpoint removal takes a moment to reach every node. A short preStop sleep, or an app that keeps serving for a few seconds after SIGTERM before closing, avoids dropped requests. The total must fit inside terminationGracePeriodSeconds, which defaults to 30 seconds, after which the container is killed with SIGKILL.