Glossary · L

Liveness and Readiness Probes

Kubernetes checks that decide whether a container is restarted (liveness) or receives traffic (readiness), plus startup probes for slow starts.

By Obseria TeamUpdated

Definition

Liveness and readiness probes are periodic health checks that the kubelet runs against containers in Kubernetes. A failing liveness probe causes the container to be restarted, a failing readiness probe removes the pod from Service endpoints so it receives no traffic. Startup probes protect slow-starting applications by delaying the other two probes.

What are liveness and readiness probes?

Liveness and readiness probes are the way Kubernetes asks a running container two different questions. The liveness probe asks: is this process still working, or is it stuck and should be restarted? The readiness probe asks: can this pod handle requests right now? Both are executed by the kubelet on the node, periodically and independently of each other. They are a specialised form of the general health check known from load balancers.

The distinction matters because the reactions are very different. A failed liveness probe leads to a container restart. A failed readiness probe only takes the pod out of the endpoints of its Service, so traffic flows to other replicas until the pod reports ready again. Nothing is restarted.

The three probe types

  • Liveness probe: detects deadlocks, hung event loops or other states the application cannot recover from. After failureThreshold consecutive failures the kubelet kills the container, and the pod's restart policy applies.
  • Readiness probe: signals temporary unavailability, for example while caches are warming up, during a dependency outage or when the instance is overloaded. Readiness is checked for the whole life of the container, not only at start.
  • Startup probe: protects slow-starting applications. As long as the startup probe has not succeeded, liveness and readiness probes are disabled. This avoids the classic loop where a liveness probe kills a JVM application before it has finished starting.

Check mechanisms and parameters

Kubernetes supports four mechanisms: httpGet (success is a status code from 200 to 399), tcpSocket (the port accepts a connection), exec (a command in the container exits with code 0) and grpc (the gRPC health checking protocol). Timing is controlled by a few fields:

FieldMeaningDefault
initialDelaySecondsWait before the first check0
periodSecondsInterval between checks10
timeoutSecondsTimeout per check1
failureThresholdConsecutive failures before action3
successThresholdConsecutive successes to count as healthy again1

A typical configuration for a web service:

startupProbe:
  httpGet: { path: /healthz, port: 8080 }
  periodSeconds: 5
  failureThreshold: 30
livenessProbe:
  httpGet: { path: /healthz, port: 8080 }
  periodSeconds: 10
readinessProbe:
  httpGet: { path: /ready, port: 8080 }
  periodSeconds: 5

Best practices and common mistakes

  • Keep liveness checks local. A liveness endpoint should only check the process itself. If it also checks the database, a database outage restarts every pod at the same time and turns a partial outage into a full one.
  • Put dependencies into readiness, carefully. Readiness can reflect critical dependencies, but if all replicas depend on the same one, they all become unready together and the Service has no endpoints at all.
  • Use a startup probe instead of a long initialDelaySeconds. It adapts to the actual start time instead of a fixed guess.
  • Make probes cheap. Probes run every few seconds on every replica. Heavy checks add load and fail under exactly the pressure you want to detect.
  • Do not hide crashes. Frequent liveness restarts mask real problems such as memory pressure. A container terminated by an OOM kill looks similar in the restart counter but has a completely different cause.

Monitoring probe behaviour

Probe failures appear as Kubernetes events (Unhealthy, Killing) and in the container's restart count. kube-state-metrics exposes metrics such as kube_pod_container_status_restarts_total and kube_pod_status_ready, and the kubelet reports probe results in prober_probe_total. Useful alerts are a rising restart rate per deployment, pods that stay unready for longer than a rollout normally takes, and a drop in ready replicas below what the service needs for high availability. Readiness flapping is also a common sign that the autoscaling configuration lags behind real load.

Probes also play a central role during rollouts. A Deployment with a rolling update strategy only continues replacing old pods once new pods report ready, so a correct readiness probe protects you from shipping a broken release to all replicas. Combined with maxUnavailable and a PodDisruptionBudget, readiness determines how much capacity remains during deployments and node maintenance.

How Obseria helps

Kubernetes monitoring in Obseria shows restarts, readiness state and probe-related events per workload next to the traces and logs of the affected pods. That way you see whether a restart was caused by a failing liveness check, an OOM kill or a deployment, and which requests were affected.

Frequently asked questions

A failing liveness probe makes the kubelet restart the container. A failing readiness probe only removes the pod from Service endpoints, so it stops receiving traffic until it reports ready again; the container keeps running.

Use a startup probe for applications that take a long or variable time to start, such as large JVM services. Liveness and readiness checks are disabled until the startup probe succeeds, which prevents premature restarts.

Usually not. If the database is down, all pods fail liveness at once and are restarted, which does not fix the database and makes recovery slower. Check external dependencies in readiness, if at all.

Without probes, Kubernetes treats a container as alive while its process runs and as ready as soon as it has started. Hung processes are not restarted and pods receive traffic before they can serve it.

Put these concepts into practice

Try Obseria free for 14 days, with OpenTelemetry and no proprietary agents.