Back to articles

Health probes done right: liveness, readiness and startup

A liveness probe that fails for the wrong reason restarts healthy containers, and it can do so when the service is under the most load. This article covers what each probe does on failure, the mistakes to look for in your manifests, a baseline configuration, and when the right liveness probe is none at all.

Probes are how the kubelet decides whether to restart your container and whether to send it traffic. A missing probe costs you a few failed requests during a rollout. A wrong one can do far more damage: a liveness probe that fails for the wrong reason restarts healthy containers, and it tends to do so at the moment the service is under the most load.

A probe configuration copied from an example works until a dependency slows down or a node gets busy, and then it can turn a partial problem into an outage.

Who this is for: engineers who own Deployments that serve traffic, and anyone who has seen a restart count climb on a pod whose process never crashed.

What you walk away with: a clear picture of what each probe does when it fails, the mistakes to look for in your own manifests, a baseline configuration, and the cases where the right liveness probe is none at all.

Everything below comes from the Kubernetes v1.37 documentation and source code. The probe behaviour was checked on one cluster (GKE 1.36.4 with Dataplane V2, 17 November 2026); autoscaling, external load balancers and gRPC over TLS were not.

The mistakes, and what they cause

A liveness probe that checks dependencies. The health endpoint queries the database, or calls a downstream service. When that dependency slows down, every replica fails its liveness probe at about the same time, and the kubelet restarts all of them. The restarted containers come back, find the dependency still slow, and get restarted again. The documentation warns that an incorrect liveness probe "can lead to cascading failures", with containers restarted under high load and more work pushed onto the pods that remain. A restart can't repair a database that is somewhere else.

The same check with the same thresholds for liveness and readiness. Readiness failing means "stop sending me traffic". Liveness failing means "kill me". With the same endpoint and the same thresholds they fail together, and the container is killed at the moment it would otherwise have been taken out of rotation and left to recover.

No startup probe on a slow starter. An application that needs 90 seconds to start, with a liveness probe on defaults, is killed within about 30 seconds, every time. The tempting workaround is a large initialDelaySeconds on the liveness probe, which still fails on the day startup takes longer than the guess.

timeoutSeconds: 1 on a container that is CPU-throttled. One second is the default. A CPU limit doesn't kill a container, but throttling can make it answer a probe too late. That is reasoning from how throttling works, not a documented effect, and a 50m limit with a trivial handler didn't show it when tested. If that probe is a liveness probe, load causes restarts, restarts shift load to the other replicas, and they are throttled next.

What each probe does when it fails

Probe Runs On failure Effect on traffic
Startup Only until it first succeeds Kubelet kills the container; restart policy applies None directly, but readiness doesn't run until it passes
Liveness For the container's whole life, after startup passes Kubelet kills the container; restart policy applies, with its back-off Indirect: the container is gone until it restarts and becomes ready
Readiness For the container's whole life, after startup passes Container marked not ready and the pod's Ready condition set to false; nothing is restarted The pod's endpoint is marked ready: false in the EndpointSlices of matching Services

The probes page says the EndpointSlice controller "removes the Pod's IP address" on a readiness failure. The EndpointSlice page and the v1.37 controller source differ: the address stays in the slice with ready: false. A Service with publishNotReadyAddresses: true is the exception: its endpoints are always ready, whatever the probe says.

Three details from the documentation:

A liveness restart shows up in the pod's restart count. Crash loop forensics covers reading those restarts.

The defaults

These apply to all three probe types unless you set them:

Field Default Notes
initialDelaySeconds 0 Counted from container start, also when a startup probe is set
periodSeconds 10 Minimum 1
timeoutSeconds 1 Minimum 1
successThreshold 1 Must be 1 for liveness and startup
failureThreshold 3 Consecutive failures before the probe counts as failed

So a liveness probe on defaults restarts a container after three consecutive failures ten seconds apart, where "failure" includes any answer slower than one second. That is around 20 to 30 seconds of failing, depending on where in the period the problem began.

Probe mechanisms

Each probe uses exactly one of four mechanisms.

httpGet sends a GET to the pod IP. Any status from 200 to 399 is a success. Some less obvious behaviour:

tcpSocket succeeds if the port accepts a connection. It tells you the process is listening, and nothing about whether it can do work.

grpc calls the standard gRPC health checking protocol and passes when the response status is SERVING. It has been stable since v1.27. A server that doesn't implement that protocol fails the probe. The port must be a number (named ports aren't supported), and the optional service field lets one health server answer liveness and readiness differently. The connection is plaintext; mode: TLS is alpha and off by default in v1.37 (GRPCContainerProbeTLS).

exec runs a command in the container and passes on exit code 0. timeoutSeconds applies to it as well: the kubelet has enforced it for exec probes since v1.20, and the gate that could switch that off has been locked since v1.35. Each run starts processes in the container, and the documentation notes that with high pod density and short periods this "might introduce an overhead on the cpu usage of the node". Keep exec for cases where nothing else fits.

The mental model

The three probes ask three different questions:

Readiness is reversible and liveness is not. A wrong readiness failure costs one pod's share of capacity for a while. A wrong liveness failure costs in-flight requests and a cold start. So readiness can be sensitive and liveness should be slow to act.

That also settles the dependency question. In the documentation's words, when the application strictly depends on a back-end service, the liveness probe passes when the application itself is healthy, and the readiness probe additionally checks the back-end.

Even on readiness, dependency checks have a cost. If every replica checks the same database and it has a brief problem, every replica becomes unready at once and the Service has no ready endpoints. kube-proxy then rejects connections to the Service (so did Dataplane V2 in the test), where the application could have returned a clear error or served the requests that don't need the database. Put a dependency in the readiness check only when the pod is useless without it.

Startup probes: budget for the worst case

A startup probe gives the container a budget of failureThreshold × periodSeconds to start. The documentation's own example sets failureThreshold: 30 and periodSeconds: 10, which allows up to 300 seconds. The probe stops the first time it succeeds, so a generous budget costs nothing on a normal start. It only sets how long a container that never starts is left running.

Size the budget for the slowest start you can foresee, such as the minutes after a node failure, when many pods start at once and compete for CPU. The liveness probe then no longer has to cover startup.

A startup probe also keeps start-up CPU out of autoscaling decisions, which HPA tuning goes into.

A baseline

For an HTTP service with a cheap health endpoint that checks only the process itself:

containers:
- name: app
  image: registry.example.com/app:1.4.2
  ports:
  - name: http
    containerPort: 8080
  startupProbe:
    httpGet:
      path: /healthz
      port: http
    periodSeconds: 5
    failureThreshold: 24      # up to 120s to start
  readinessProbe:
    httpGet:
      path: /ready
      port: http
    periodSeconds: 5
    timeoutSeconds: 2
    failureThreshold: 2       # out of rotation after about 10s
  livenessProbe:
    httpGet:
      path: /healthz
      port: http
    periodSeconds: 10
    timeoutSeconds: 5
    failureThreshold: 6       # restarted after about 60s of failing

The reasoning behind the numbers, which are a starting point:

If you have only one endpoint, the documentation describes an accepted variant: use the same low-cost endpoint for both probes, with a higher failureThreshold on liveness, so the pod is seen as not ready for a while before it is killed. Sharing an endpoint isn't the mistake. Sharing one that checks dependencies is, and so is sharing thresholds.

The trade-off is detection time. A deadlocked process serves nothing for about ten seconds until readiness removes it, and stays down for about a minute until it is restarted. With one replica that is a minute of downtime, and tighter liveness settings would shorten it at the price of more false restarts.

When to have no liveness probe

The documentation is plain about this: if the process "is able to crash on its own whenever it encounters an issue or becomes unhealthy, you do not necessarily need a liveness probe". The kubelet already restarts a container whose process exits, according to the pod's restartPolicy.

A liveness probe earns its place when the process can hang without exiting: a deadlock, a stuck event loop, an exhausted thread pool. If you can't name the hang you are guarding against, start without one. Run with readiness and startup probes, and make the application exit on unrecoverable errors.

Probes and termination

Probe-level terminationGracePeriodSeconds. When a liveness or startup probe fails, the kubelet stops the container using the pod's grace period, which may be minutes for a workload that drains slowly. A hung process won't use that time well. Since v1.28 (stable) you can set a shorter grace period on the probe itself:

spec:
  terminationGracePeriodSeconds: 120   # normal shutdown: time to drain
  containers:
  - name: app
    livenessProbe:
      httpGet:
        path: /healthz
        port: http
      failureThreshold: 6
      terminationGracePeriodSeconds: 10   # liveness failure: don't wait 120s

The API server rejects this field on readiness probes.

Readiness during shutdown. When a pod is deleted, the endpoint's ready condition in the EndpointSlice is set to false because the pod is terminating, whatever its readiness probe says. The documentation notes that you "do not necessarily need a readiness probe" to drain requests on deletion. In the v1.37 kubelet source, liveness and startup probes stop once the pod has a deletion timestamp, and the readiness probe keeps running. What it still controls is the endpoint's serving condition, which tells consumers whether a terminating pod can still answer.

So a readiness endpoint that fails on SIGTERM does little for Service traffic, and it doesn't close the gap in which requests still arrive. Graceful shutdown covers that sequence.

Readiness gates

A readiness gate adds a condition from outside the pod to its readiness. You list condition types under spec.readinessGates, and the pod is ready only when all its containers are ready and every listed condition is True. A missing condition counts as False. A controller has to set those conditions through the API. One use is a load-balancer controller that sets the condition once the external load balancer has registered the pod, so a rollout doesn't run ahead of the infrastructure in front of it.

Sidecar containers

Native sidecars are init containers with restartPolicy: Always, stable since v1.33. Unlike ordinary init containers, they support all three probes, and two of them change pod behaviour:

initContainers:
- name: proxy
  image: registry.example.com/proxy:2.1
  restartPolicy: Always
  startupProbe:
    httpGet:
      path: /ready
      port: 15021
    periodSeconds: 2
    failureThreshold: 30

Checking what you run

Probe failures appear as events in kubectl describe pod <pod>:

Warning  Unhealthy  49s (x6 over 99s)  kubelet  spec.containers{app}: Liveness probe failed: HTTP probe failed with statuscode: 500
Normal   Killing    49s                kubelet  spec.containers{app}: Container app failed liveness probe, will be restarted

To find containers in a namespace that have a liveness probe but no startup probe (sidecars under initContainers aren't covered):

kubectl get pods -n <namespace> -o json | jq -r '
  .items[] | .metadata.name as $p | .spec.containers[]
  | select(.livenessProbe != null and .startupProbe == null)
  | "\($p)/\(.name) liveness without startup: timeout=\(.livenessProbe.timeoutSeconds)s period=\(.livenessProbe.periodSeconds)s failures=\(.livenessProbe.failureThreshold)"'

kubectl get events --field-selector reason=Unhealthy -A lists probe failures across the cluster. Events expire, so look soon after the fact (see the events guide).

Checklist

  1. Liveness checks the process only. No database, no downstream calls, no shared locks.
  2. Liveness is slower than readiness. Different thresholds, even on a shared endpoint.
  3. Slow starters have a startup probe with failureThreshold × periodSeconds above the worst-case start.
  4. Timeouts are deliberate. One second is a default, and it is short for a throttled container.
  5. Exec probes are the exception.
  6. No liveness probe without a named hang it protects against.
  7. Long grace periods have a probe-level override on liveness.
  8. Sidecars that carry traffic have startup and readiness probes.