Set a container running in Kubernetes and sooner or later it will fail in a way the container runtime cannot see. The process is still up, but it stopped answering requests. Or it crashed and the platform never noticed. Kubernetes probes explained in one line: they are health checks the kubelet runs against your containers so the platform can restart dead ones and route traffic only to healthy ones. This guide covers liveness, readiness, and startup probes, with YAML you can copy and the misconfigurations that cause the most production incidents.
Why Kubernetes needs three different probes
A container raises three separate health questions, and mixing them up is where most trouble starts. Is the process dead? Is it ready for traffic? Has it finished starting? One check cannot answer all three, because the correct response differs each time: restart the container, hold back traffic, or wait longer. If you are new to the platform, this practical introduction to Kubernetes covers the building blocks this guide assumes you know.
Probes run through the kubelet, the agent on every node. Each probe uses one of four mechanisms: an HTTP GET against an endpoint, a TCP socket connection, a command executed inside the container, or a gRPC call. The same four mechanisms attach to liveness, readiness, and startup probes; what changes is what Kubernetes does with the result.
Kubernetes probes explained: liveness probes restart dead containers
A liveness probe asks one question: is this container still alive? When the probe fails enough times in a row, the kubelet kills the container and restarts it according to the pod’s restart policy. Liveness exists for deadlocks, frozen event loops, and corrupted in-memory state, situations where the process is running but will never recover on its own.
The classic mistake is making the liveness probe too ambitious. It should check one thing: can this container do its core job. Do not check the database, the cache, or any downstream API from a liveness probe. If the database has a bad minute and your liveness probe reports failure, the kubelet starts restarting containers that were fine, and a partial outage becomes a full one. Liveness probes catch crashes, not load problems. For load, you want autoscaling with the Horizontal Pod Autoscaler instead.
Readiness probes decide who gets traffic
A readiness probe asks: can this container take requests right now? When it fails, Kubernetes pulls the pod out of the service’s endpoints. Traffic stops flowing to it, but nothing restarts. The container keeps running and rejoins automatically when the probe passes again.
Here is a kubernetes readiness probe example for an app that loads a model or warms a cache before serving:
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
Use readiness when startup work varies between deploys, when a pod needs to drain before shutdown, or when temporary overload should shed traffic instead of triggering restarts. Keep the check cheap and local, it runs every few seconds on every pod.
Startup probes protect slow-starting apps
A startup probe exists for one scenario: applications that take a long time to start. While the startup probe is still running, liveness and readiness probes stay disabled. Once the startup probe succeeds a single time, Kubernetes hands control to the other probes and the startup probe retires.
Without it, teams set a huge initialDelaySeconds on the liveness probe to survive slow boots, which delays failure detection for the entire life of the pod. A kubernetes startup probe for slow apps is the cleaner fix:
startupProbe:
httpGet:
path: /started
port: 8080
periodSeconds: 10
failureThreshold: 30
This gives the app up to five minutes to start (ten seconds times thirty failures) without the liveness probe interfering, and the moment the app reports started, normal health checking begins. JVM services, legacy monoliths, and apps that run migrations on boot are the usual candidates.
A complete YAML example with all three probes
Most production deployments combine all three. The pattern looks like this:
containers:
- name: api
image: registry.example.com/api:1.4.2
ports:
- containerPort: 8080
startupProbe:
httpGet:
path: /started
port: 8080
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet:
path: /healthz
port: 8080
periodSeconds: 15
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 10
failureThreshold: 3
Notice the three endpoints do different jobs. /started flips once during boot, /healthz checks the process is alive, and /ready confirms the app can take traffic right now. Reusing one endpoint for everything defeats the point of having three probes.
Liveness vs readiness vs startup: which one when
| Probe | Question it answers | On failure | Use it for |
|---|---|---|---|
| Liveness | Is the container dead? | Container restarts | Deadlocks, frozen processes, unrecoverable state |
| Readiness | Can it take traffic? | Removed from endpoints | Warm-up, cache loading, overload shedding |
| Startup | Has it finished starting? | Other probes stay disabled | Slow boots, migrations, heavy init work |
Four misconfigurations that cause real outages
1. Liveness probes that check dependencies. The most common incident pattern: liveness hits an endpoint that queries the database, the database slows down, every pod fails liveness at once, and the kubelet restarts the whole fleet during an outage it did not cause. Keep liveness local. Move dependency checks to readiness if you must check them at all.
2. Aggressive liveness on slow starters, no startup probe. A Java service takes ninety seconds to boot. Liveness with initialDelaySeconds of thirty kills it at thirty seconds, the pod restarts, boots for thirty seconds, dies again, and you get CrashLoopBackOff forever. The fix is a startup probe, not a bigger delay.
3. Copy-pasted timings for every probe. A kubernetes liveness probe configuration lifted straight from a tutorial rarely fits your app. Liveness can afford to be slower and more forgiving. Readiness should react fast so traffic moves away quickly. Startup should allow the worst-case boot time you have actually measured.
4. Readiness so strict the pod never serves. If readiness requires a fully warm cache and the cache only warms from live traffic, the pod waits forever. Rolling updates stall, old pods keep serving, and the deploy never completes. Readiness should mean safe to receive some traffic, not fully optimized.
Tuning period, timeout, and thresholds
Three numbers control every probe. periodSeconds is how often the check runs, timeoutSeconds is how long to wait for a response, and failureThreshold is how many consecutive failures trigger action. Multiply period by threshold to get your reaction time: fifteen seconds times three failures means Kubernetes acts after about forty-five seconds of continuous failure.
Start conservative, with longer periods and higher thresholds, then tighten once you know how the app behaves under load. Probe timeouts should sit comfortably below the period so checks do not pile up. successThreshold can stay at its default of one for liveness and startup; readiness is the only probe where raising it to two or three makes sense, to avoid flapping traffic between pods. While you tune, run experiments in separate Kubernetes namespaces so test workloads do not skew your measurements.
Pre-deploy checklist
- Each probe has its own endpoint and its own job.
- Slow-starting app? A startup probe is configured with a measured worst-case boot time.
- Liveness checks the container only, never external dependencies.
- Readiness means safe for traffic, not perfectly warm.
- Timings start generous, then tighten after observing real behavior.
- Failure is tested on purpose: kill the process, block the endpoint, watch what Kubernetes does.
Still running everything on one machine? Read when to use Kubernetes over Docker Compose before migrating. Probes are one of several operational concerns that only pay off once you actually need orchestration.