Liveness, readiness and startup probes

Intermediate · 23 min

How the kubelet decides a container is alive, ready or still starting, what each probe failure does, and probes that don't cause outages.

Before thisPods in depthServices: ClusterIP, NodePort and LoadBalancer

Cloud With VarJosh · 30 min · from 7:00

Liveness, readiness and startup probes

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Cloud With VarJoshReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • The kubelet runs probes, not the control plane. A liveness failure restarts the container, a readiness failure removes the Pod from Service endpoints, and a startup probe holds the other two off until the app has booted.
  • Each probe is httpGet, tcpSocket, grpc or exec. HTTP passes on any status from 200 to 399. The API server defaults periodSeconds to 10, timeoutSeconds to 1 and failureThreshold to 3.
  • Readiness starts as failing and liveness starts as passing, so a new Pod gets no traffic until its first readiness success, and isn't killed before its first liveness failure streak.
  • A startup probe's budget is failureThreshold × periodSeconds. It replaces a long initialDelaySeconds on the liveness probe, which would slow down detection for the container's whole life.
  • Liveness checks should test only the process itself. A liveness probe that calls the database restarts every replica when the database blips and turns a dependency outage into your outage.
  • During termination the kubelet stops liveness and startup probes but keeps running readiness, so a Pod being deleted drops out of endpoints instead of being restarted.

Running is not the same as working

A container’s main process can be alive and useless. It can deadlock, exhaust a connection pool, or spend its first minute warming caches while already listening on its port. Kubernetes restarts containers whose process exits, but a process that hasn’t exited looks fine from the outside. And a Service will happily route requests to a Pod that can’t answer them yet.

Probes close that gap. They are checks the kubelet on each node runs against each container, on a timer, and they answer three different questions:

  • Liveness: is this process wedged beyond recovery? If yes, kill it and start a new one.
  • Readiness: should this Pod receive traffic right now? If no, take it out of the load balancer but leave it running.
  • Startup: has the app finished booting? Until it has, don’t run the other two.

The general idea of liveness against readiness is covered in health checks and chaos engineering. This lesson is about how Kubernetes implements them, and the mistakes that turn a probe into the cause of an outage.

Four ways to probe

Every probe uses one handler:

Handler Passes when
httpGet the kubelet gets a status from 200 to 399
tcpSocket a TCP connection to the port opens
grpc the gRPC Health Checking service returns SERVING
exec a command run inside the container exits 0

The HTTP prober in pkg/probe/http reads at most 10 KB of the body and sends User-Agent: kube-probe/<version>, which is handy for filtering probes out of access logs. Requests come from the kubelet on the node, to the Pod’s IP. exec probes are the most expensive: each one starts a process inside the container, so a 1-second exec probe across hundreds of Pods costs real CPU.

A manifest with all three

apiVersion: v1
kind: Pod
metadata:
  name: api
spec:
  containers:
  - name: api
    image: ghcr.io/example/api:1.4.2
    ports:
    - name: http
      containerPort: 8080
    startupProbe:
      httpGet: {path: /healthz, port: http}
      periodSeconds: 5
      failureThreshold: 24
    livenessProbe:
      httpGet: {path: /healthz, port: http}
    readinessProbe:
      httpGet: {path: /ready, port: http}
      periodSeconds: 5

Applying it to a local API server and reading the Pod back shows what the server filled in for the fields left out:

liveness:  {"failureThreshold":3,"httpGet":{"path":"/healthz","port":"http","scheme":"HTTP"},"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}
readiness: {"failureThreshold":3,"httpGet":{"path":"/ready","port":"http","scheme":"HTTP"},"periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}
startup:   {"failureThreshold":24,"httpGet":{"path":"/healthz","port":"http","scheme":"HTTP"},"periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}

So a bare liveness probe checks every 10 seconds, gives each attempt one second, and acts after three failures in a row: about 30 seconds from hang to restart. That one-second timeout is the default people most often trip on. A GC pause or a slow disk makes a healthy app miss it.

Validation also enforces the asymmetry between probes. Asking for two successes on liveness gets a hard rejection:

The Pod "bad" is invalid:
* spec.containers[0].livenessProbe.successThreshold: Invalid value: 2: must be 1
* spec.containers[0].startupProbe.successThreshold: Invalid value: 3: must be 1

What each failure does

The kubelet’s probe worker (pkg/kubelet/prober/worker.go) makes the semantics concrete. Each probe type starts from a different initial result: readiness starts as Failure, liveness as Success, startup as Unknown. So a new container receives no traffic until its first readiness pass, and is never killed just for being new.

When a probe’s result crosses its threshold:

  • Liveness fails → the kubelet kills the container (with the normal grace period, or the probe’s own terminationGracePeriodSeconds if set) and the Pod’s restartPolicy brings it back. The restart counter goes up, and repeated restarts back off into CrashLoopBackOff.
  • Readiness fails → the container’s ready becomes false, the Pod’s Ready condition goes False, and the EndpointSlice controller marks that endpoint not ready. kube-proxy and most ingress controllers stop sending it new connections. Nothing restarts. When the probe passes successThreshold times again, traffic returns.
  • Startup hasn’t passed → liveness and readiness are not run at all. If it fails failureThreshold times, the container is killed like a liveness failure.

One detail from the same file is easy to miss. Once a Pod has a deletion timestamp, the kubelet stops liveness and startup probes and records success, but keeps running readiness. A terminating Pod isn’t restarted halfway through shutting down. It drops out of endpoints, which is what you want, and what the next lesson on termination builds on.

Startup probes replace long initial delays

Before startup probes, slow-starting apps got initialDelaySeconds: 120 on their liveness probe. That delay applies to every container start, forever. A container that hangs ten seconds after a restart goes undetected for two minutes.

A startup probe gives the boot its own budget, failureThreshold × periodSeconds, 24 × 5 = 120 seconds above, and hands over the moment it succeeds. Liveness can then keep tight timings for the rest of the container’s life. Use initialDelaySeconds only for small, fixed waits.

Rules that prevent probe outages

  • Liveness tests only the process. Can it serve a trivial request? Never check the database, cache or another service in liveness. If the database blips, every replica fails at once, and restarting all of them can’t fix the database but can take you down while it recovers.
  • Readiness can be stricter, but carefully. Failing readiness when a hard dependency is down sheds load, but if all replicas go unready together the Service has no endpoints and clients get connection errors instead of fast 503s.
  • Don’t reuse liveness as readiness by habit. They answer different questions. A Pod may be alive but deliberately unready while it drains or reloads.
  • Give timeouts headroom. Raise timeoutSeconds above the default 1 second if p99 latency of the health path ever approaches it.
  • Probe something cheap. A health handler should not allocate much, take locks the request path holds, or log at info level on every hit.

About the video

The embed is a clip of Cloud With VarJosh’s “Day 23: MASTER Kubernetes Health Probes | Readiness vs Liveness vs Startup”, part of a 2025 CKA course, from the “Readiness vs Liveness vs Startup Probes” chapter (7:00) to the end of the startup-probe demo (36:43), about 30 minutes. Going by its chapter list and description, it compares the three probes, walks through the probe mechanisms, and demos each probe on a real cluster, which this lesson can’t do. Skip back to 0:30 for the course’s own “why” section. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from its “English (US) original” audio track. Anton Putra’s three-minute summary in deeper is a good refresher.

What was run: the manifest above was applied to a local Kubernetes v1.37.3 API server whose nodes run no containers, and the defaulted probe fields and the successThreshold rejection are real output from it. No probe ever executed, since there is no kubelet. Initial results, hand-over, behaviour during deletion and the HTTP status range were read from the kubelet’s prober/worker.go and pkg/probe/http/http.go in the v1.37.3 source; failure effects are from the Pod lifecycle docs, checked 2026-11-28.

Where this fits

Readiness is half of a clean shutdown. Next: Pod termination and graceful shutdown.

Check yourself

  1. 01A Java service takes up to 90 seconds to start. Someone sets initialDelaySeconds: 120 on its liveness probe. What does that cost, and what is better?

    Every container waits two minutes before any liveness check, so a hang right after a restart goes undetected that long, and a fast start still wastes the delay. A startupProbe with periodSeconds: 5 and failureThreshold: 24 allows up to 120 seconds, hands over to liveness the moment it succeeds, and lets liveness keep tight timings.

  2. 02Your readiness probe returns 503 for one replica out of four. What happens to that Pod?

    It keeps running and isn't restarted. Its Ready condition goes False and its endpoints are marked not ready, so Services and most ingress controllers stop sending it new requests until the probe passes again.

  3. 03Why does the API server reject successThreshold: 2 on a liveness probe?

    Liveness and startup probes act on a single transition (restart, or hand over), so validation requires successThreshold to be 1. Only readiness can demand several consecutive successes before marking the Pod ready again.

  4. 04Every replica of a service restarted at the same moment during a 30-second database failover. What probe mistake probably caused it?

    The liveness endpoint checked the database. When the database was unreachable all liveness probes failed together and the kubelets restarted every container, which can't fix a database. Dependency checks belong, if anywhere, in readiness.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark