Pods and workloadsLesson 4 of 7
  1. Pod anatomy, not reconciled
  2. Pod lifecycle, restarts and termination, not reconciled
  3. Init containers and native sidecars, not reconciled
  4. Probes: startup, readiness and liveness, not reconciled
    1. Three questions
    2. Four mechanisms
    3. Timing fields
    4. What failure does
    5. Startup budget
    6. Anti-patterns
    7. Readiness and rollouts
  5. Deployments and rolling updates, not reconciled
  6. DaemonSets, not reconciled
  7. Jobs and CronJobs, not reconciled

Probes: startup, readiness and liveness

Choose startup, readiness and liveness probes, configure all four mechanisms with sensible timing, and predict what each failure does to traffic and restarts.

  • 24 min
  • 4 objectives
  • 7 scenes

Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.

Reconcile, in 7 scenes

Three questions

The kubelet can ask each container three different questions, and each has its own probe:

  • Startup: has the application finished starting? A startup probeA probe that runs only while a container is starting. Until it succeeds, the kubelet runs no liveness or readiness probes; if it fails too often, the container is killed. answers this once, at the beginning.
  • Readiness: should this container receive traffic at this moment? A readiness probeA probe that runs for the container’s whole life and decides whether the pod is Ready, and so whether Services send it traffic. answers continuously. The answer can change from yes to no and back.
  • Liveness: is the process stuck in a way only a restart will fix? A liveness probeA probe that runs for the container’s whole life; enough consecutive failures make the kubelet kill and restart the container. answers continuously too, but its “no” is drastic.

A container without a probe of a given kind is treated as passing it. Without a readiness probe, a container is ready the moment its process starts, often before it can serve. Without a liveness probe, the kubelet restarts the container only when the process exits. That is the right behaviour for a process that crashes when something goes badly wrong, so not every container needs a liveness probe. Every container that serves traffic needs a readiness probe.

ExplainerStartup, readiness and liveness probes

startupProbe

Holds back the other probes until it passes; at its threshold the container is killed.

initialDelaySeconds0 s

Seconds after the container starts before the first check.

periodSeconds5 s

Seconds between checks.

failureThreshold6

Consecutive failures before the kubelet acts.

The app

Answers health checks after20 s
Hangs after90 s

Measured from each start, so a restart clears the hang until it recurs.

First Ready
25 s
Restarts
2
Startup probe
gives up at 25 s
Time

0 s: The container starts. Startup probe failed, 1 of 6 in a row.

Tune each probe and play the timeline. A failing readiness probe takes the pod out of its Service's endpoints; a failing liveness probe restarts the container; the startup probe holds both back until it passes.

Four mechanisms

Each probe uses exactly one of four mechanisms. The kubelet runs them from the node, against the pod’s IP address, so a server that listens only on 127.0.0.1 fails every network probe.

MechanismPasses whenNotes
httpGetThe response status is at least 200 and below 400.Sends GET to path on port, with the header User-Agent: kube-probe/1.37. scheme: HTTPS skips certificate verification. The kubelet stops reading the body after 10KiB, so point it at a small health endpoint.
tcpSocketA TCP connection opens.Proves only that something accepts connections, not that it answers correctly.
grpcThe grpc.health.v1.Health/Check call returns SERVING.GA since Kubernetes 1.27. port is required and must be a number, not a named port. The optional service field picks which health service to ask. TLS needs mode: TLS and the GRPCContainerProbeTLS feature gate, alpha in 1.37, and even then the kubelet does not verify the certificate.
execThe command exits 0.Runs inside the container, so the binary must exist in the image. Each run forks processes, which adds node CPU on dense nodes with short periods.

Pick the cheapest mechanism that tests what you care about. An HTTP server should expose small, dedicated endpoints and use httpGet. A gRPC server should implement the standard health service and use grpc, which answers per service without a second port. tcpSocket suits servers that speak some other protocol, as long as an open port is meaningful. Reach for exec when the check needs a client that only exists inside the container, such as redis-cli or pg_isready.

httpGet and tcpSocket accept a named port such as http, which keeps the probe correct if the port number changes. An exec probe and a tcpSocket probe on one container:

apiVersion: v1
kind: Pod
metadata:
  name: cache
spec:
  containers:
  - name: redis
    image: redis:8.10
    ports:
    - containerPort: 6379
    readinessProbe:
      exec:
        command: ["redis-cli", "ping"]
      periodSeconds: 5
    livenessProbe:
      tcpSocket:
        port: 6379
      periodSeconds: 10

A grpc probe on a server that implements the gRPC health checking protocol, here etcd on its client port:

apiVersion: v1
kind: Pod
metadata:
  name: etcd-grpc
spec:
  containers:
  - name: etcd
    image: registry.k8s.io/etcd:3.7.0-0
    command: ["etcd", "--data-dir=/var/lib/etcd", "--listen-client-urls=http://0.0.0.0:2379", "--advertise-client-urls=http://127.0.0.1:2379"]
    ports:
    - containerPort: 2379
    startupProbe:
      grpc:
        port: 2379
      periodSeconds: 2
      failureThreshold: 30
    livenessProbe:
      grpc:
        port: 2379
      periodSeconds: 10
      timeoutSeconds: 2

Timing fields

Five fields decide when a probe runs and how many results it takes to change its verdict:

FieldDefaultMeaning
initialDelaySeconds0Wait this long after the container starts before the first probe. With a startup probe, the liveness and readiness delays count from the moment it succeeds.
periodSeconds10Time between probes. Minimum 1.
timeoutSeconds1How long one probe may take before it counts as a failure. Minimum 1.
failureThreshold3Consecutive failures before the probe’s verdict turns to failed.
successThreshold1Consecutive successes before a failed probe passes again. It must be 1 for liveness and startup probes, and validation rejects any other value; only readiness probes accept more.

A liveness or startup probe may also set its own terminationGracePeriodSeconds, stable since Kubernetes 1.28, so a probe-triggered kill does not wait out a long pod-level grace period meant for planned shutdowns. Readiness probes cannot set it, because they never kill anything.

The time from a hang to a verdict is roughly failureThreshold × periodSeconds, plus up to one timeoutSeconds. With the defaults, a liveness probe restarts a hung container about 30 seconds after it stops answering.

What failure does

The three probes fail in different ways, and only two of them restart anything.

Readiness. After failureThreshold consecutive failures, the kubelet marks the container not ready and sets the pod’s Ready condition to False. The EndpointSlice controller then marks the pod’s endpoints ready: false in the EndpointSlices of every Service that selects it, and kube-proxy, ingress controllers and load balancers stop sending it new connections. The container keeps running and keeps being probed. When the probe passes again, traffic comes back.

Readiness fails, nothing restarts
kubectl get pods -l app=inventory
NAME                         READY   STATUS    RESTARTS   AGE
inventory-7c757cb64f-4qkml   0/1     Running   0          60s
inventory-7c757cb64f-6z4nz   0/1     Running   0          60s
kubectl get deployment inventory
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
inventory   0/2     2            0           60s
kubectl get events --field-selector reason=Unhealthy
LAST SEEN   TYPE      REASON      OBJECT                           MESSAGE
56s         Warning   Unhealthy   pod/inventory-7c757cb64f-4qkml   Readiness probe failed: Get "http://10.244.1.2:8080/readyz": dial tcp 10.244.1.2:8080: connect: connection refused
1s          Warning   Unhealthy   pod/inventory-7c757cb64f-4qkml   Readiness probe failed: HTTP probe failed with statuscode: 404
56s         Warning   Unhealthy   pod/inventory-7c757cb64f-6z4nz   Readiness probe failed: Get "http://10.244.3.2:8080/readyz": dial tcp 10.244.3.2:8080: connect: connection refused
1s          Warning   Unhealthy   pod/inventory-7c757cb64f-6z4nz   Readiness probe failed: HTTP probe failed with statuscode: 404
kubectl get endpointslices -l kubernetes.io/service-name=inventory
NAME              ADDRESSTYPE   PORTS   ENDPOINTS               AGE
inventory-bhphj   IPv4          8080    10.244.1.2,10.244.3.2   60s
kubectl get endpointslices -l kubernetes.io/service-name=inventory -o jsonpath='{range .items[*].endpoints[*]}{.addresses[0]} ready={.conditions.ready}{"\n"}{end}'
10.244.1.2 ready=false
10.244.3.2 ready=false

The probe asks for /readyz, which this app does not serve: the first probes found nothing listening yet, and the later ones got a 404. RESTARTS stays at 0, and the EndpointSlice table lists both addresses even though neither will receive traffic. Read the conditions, not the address list. EndpointSlices are the source of truth for Service backends, GA since Kubernetes 1.21; the v1 Endpoints API is deprecated since 1.33. It is still served, with a warning, and it drops not-ready addresses into a separate list rather than showing a condition.

Liveness. After failureThreshold consecutive failures, the kubelet kills the container, honouring the grace period, and restarts it under the pod’s restartPolicy. The event reads Container app failed liveness probe, will be restarted, and a process that dies of the SIGTERM shows exit code 143 in lastState. Restarts go through the normal crash-loop back-off, so a container that keeps failing its liveness probe ends up in CrashLoopBackOff.

A probe that cannot run at all, for example because the kubelet cannot resolve a named port, has the result Unknown, and the kubelet takes no action and tries again. Before its first run, a readiness probe counts as failed, which is why a pod with a readiness probe never receives traffic until the probe has passed once.

Startup. If the startup probe has not succeeded after failureThreshold attempts, the kubelet kills the container just as a liveness failure would. Once it succeeds, it does not run again until the container restarts.

Startup budget

A slow-starting application and a liveness probe tuned for fast deadlock detection are a bad combination. This Deployment runs an app that needs about 45 seconds to warm its cache, with a liveness probe that gives up after three failures ten seconds apart:

Liveness kills the app before it can start
kubectl get pods -l app=reportsNAME                       READY   STATUS    RESTARTS      AGE
reports-568df5c94f-4qkml   0/1     Running   1 (10s ago)   35s
reports-568df5c94f-6z4nz   0/1     Running   1 (10s ago)   35skubectl get events --field-selector reason=KillingLAST SEEN   TYPE     REASON    OBJECT                         MESSAGE
11s         Normal   Killing   pod/reports-568df5c94f-4qkml   Container app failed liveness probe, will be restarted
11s         Normal   Killing   pod/reports-568df5c94f-6z4nz   Container app failed liveness probe, will be restartedkubectl logs deploy/reports --previousFound 2 pods, using pod/reports-568df5c94f-4qkml
{"time":"2026-11-19T09:00:34.258Z","level":"INFO","msg":"starting slow-start","version":"1.0.0","pid":1}
{"time":"2026-11-19T09:00:34.258Z","level":"INFO","msg":"warming cache","expected_seconds":45}

The liveness probe fails at 0, 10 and 20 seconds, so every run is killed at about 20 seconds, 25 seconds short of finishing. The tempting fix, a long initialDelaySeconds on the liveness probe, is a guess at one fixed number: a start slower than the guess is still killed, and after every restart a hang inside the delay goes unnoticed. A startup probe is the right tool. Its budget is

initialDelaySeconds + failureThreshold × periodSeconds

and the liveness probe keeps its fast settings, because it does not start until the startup probe has passed. Size the budget for the slowest start you expect, not the typical one: a cold node pulling a large image or a cache rebuilt from scratch. Here 18 × 5 = 90 seconds gives a 45-second start twice its measured time, while still checking every five seconds so the pod is ready soon after it starts:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: reports
spec:
  replicas: 2
  selector:
    matchLabels:
      app: reports
  template:
    metadata:
      labels:
        app: reports
    spec:
      containers:
      - name: app
        image: ghcr.io/kx-labs/slow-start:1.0
        ports:
        - name: http
          containerPort: 8080
        startupProbe:
          httpGet:
            path: /healthz
            port: http
          periodSeconds: 5
          failureThreshold: 18
        readinessProbe:
          httpGet:
            path: /ready
            port: http
          periodSeconds: 5
        livenessProbe:
          httpGet:
            path: /healthz
            port: http
          periodSeconds: 10
          timeoutSeconds: 2
          failureThreshold: 3

The startup probe checks the same endpoint as the liveness probe, so once it passes, the liveness probe starts against an endpoint that is already answering. Adding the same 90-second startup probe to the running Deployment:

A startup probe buys the time it needs
kubectl patch deployment reports --type=json -p '[{"op":"add","path":"/spec/template/spec/containers/0/startupProbe","value":{"httpGet":{"path":"/healthz","port":"http"},"periodSeconds":5,"failureThreshold":18}}]'
deployment.apps/reports patched
kubectl get pods -l app=reports
NAME                       READY   STATUS    RESTARTS     AGE
reports-568df5c94f-6z4nz   0/1     Running   4 (7s ago)   95s
reports-56fcc7d7f5-ddv2r   0/1     Running   0            5s
reports-56fcc7d7f5-dlsn9   1/1     Running   0            60s
kubectl get pods -l app=reports
NAME                       READY   STATUS    RESTARTS   AGE
reports-56fcc7d7f5-ddv2r   1/1     Running   0          65s
reports-56fcc7d7f5-dlsn9   1/1     Running   0          2m
kubectl get endpointslices -l kubernetes.io/service-name=reports -o jsonpath='{range .items[*].endpoints[*]}{.addresses[0]} ready={.conditions.ready}{"\n"}{end}'
10.244.1.3 ready=true
10.244.2.3 ready=true

Anti-patterns

Most probe incidents come from a handful of designs that look reasonable in review.

A liveness probe that checks a dependency. If /healthz queries the database, a database outage fails the liveness probe in every replica at once, and the kubelet restarts all of them. Restarting the app cannot fix the database. Every replica goes into crash-loop back-off, reconnect storms hit the database as it recovers, and an outage in one component becomes an outage of everything that depends on it. A liveness check should answer only “is this process able to make progress”, from state the process holds itself.

Readiness that checks a shared dependency. The Kubernetes docs do suggest that a readiness probe may check strict back-end dependencies, so that traffic does not reach pods that can only return errors. Weigh what it costs: when the dependency is shared by every replica, one failure marks every replica unready together and the Service is left with no endpoints, so clients get connection errors instead of a useful error page. Prefer readiness that reflects the pod’s own ability to serve, and let the application report a degraded dependency in its responses.

Identical readiness and liveness probes. Pointing both at the same cheap endpoint is fine, and the docs describe it as a common pattern, provided liveness has a higher failureThreshold so a struggling pod is taken out of rotation well before it is killed. With identical thresholds, every moment of overload that should only pause traffic also restarts the container, and every restart drops whatever work was in flight.

A 1-second timeout on a slow handler. timeoutSeconds defaults to 1. A health handler that takes a lock, logs synchronously or waits behind real traffic can exceed it under load, exactly when the pod is busiest. A liveness probe then restarts the busiest pods and shifts their load onto the rest, which fail in turn. Keep health handlers trivial, and raise timeoutSeconds for anything that is not.

Readiness and rollouts

A Deployment counts a pod as available once it has been ready for minReadySeconds, which defaults to 0. A rolling update replaces old pods only as fast as new ones become available, within maxSurge and maxUnavailable. Readiness therefore gates the whole rollout: a new version that never passes its readiness probe stalls the update while the remaining old pods keep serving, and after progressDeadlineSeconds (600 by default) the Deployment reports Progressing=False with reason ProgressDeadlineExceeded. Nothing rolls back on its own; kubectl rollout undo does that.

minReadySeconds adds a soak period: a pod that passes readiness and then crashes within it never counts as available, so the rollout does not go on to replace more of the pods that worked. A few seconds of minReadySeconds catches the app that answers its first probe and then falls over.

Some readiness lives outside the container. spec.readinessGates, stable since Kubernetes 1.14, lists extra pod condition types, and the pod is Ready only when every container is ready and every listed condition is True. A controller sets the condition, typically a load balancer controller confirming that its target for the pod is healthy. Until it does, the pod stays out of its Services and the rollout waits, and kubectl get pods -o wide shows the gates in its READINESS GATES column.

Readiness also ends with the pod. When a pod is deleted, its endpoints turn ready: false and terminating: true at once, whatever the readiness probe says, so a readiness probe is not needed to drain traffic at shutdown.

Watch the three probes act

  1. kubectl --context kind-kx apply -f https://k8s.io/examples/pods/probe/http-liveness.yaml
  2. kubectl --context kind-kx get pod liveness-http -w
  3. kubectl --context kind-kx get events --field-selector involvedObject.name=liveness-http
  4. kubectl --context kind-kx delete pod liveness-http
  5. kubectl --context kind-kx create deployment inventory --image=nginx:1.31 --port=80
  6. kubectl --context kind-kx patch deployment inventory --type=json -p '[{"op":"add","path":"/spec/template/spec/containers/0/readinessProbe","value":{"httpGet":{"path":"/readyz","port":80},"periodSeconds":5}}]'
  7. kubectl --context kind-kx expose deployment inventory --port=80
  8. kubectl --context kind-kx get endpointslices -l kubernetes.io/service-name=inventory -o yaml
  9. kubectl --context kind-kx delete deployment,service inventory

For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. The upstream liveness-http example serves 200 for 10 seconds and then 500, so the kubelet restarts it after about 20 seconds, and again after each back-off; press Ctrl+C to stop the watch. nginx answers /readyz with 404, so the inventory pods run but stay out of their Service.

Actual state

Check your understanding

5 checks

Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.

  1. Check 1 of 5

    A container has a startup probe, a readiness probe and a liveness probe. What runs while the startup probe has not yet succeeded?

  2. Check 2 of 5

    A startup probe has initialDelaySeconds: 0, periodSeconds: 10 and failureThreshold: 30. Roughly how long can the container take to start before it is killed?

  3. Check 3 of 5

    You set successThreshold: 2 on a liveness probe so that one lucky success does not count. What happens?

  4. Check 4 of 5

    A running pod starts failing its readiness probe. Its liveness probe still passes. What changes?

  5. Check 5 of 5

Lesson not yet reconciled

Desired: 4 objectives, 0 metReconciled: 4 of 4 objectives met

  • Choose startup, readiness and liveness probes for a workload and say what each failure does. (not yet met)
  • Configure exec, httpGet, tcpSocket and grpc probes with sensible timing. (not yet met)
  • Explain why a liveness probe must not check downstream dependencies. (not yet met)
  • Compute how long a container may take to start before its startup probe gives up. (not yet met)

Pass every check above to reconcile this lesson.

Every check has passed, so the desired state is met. First-try accuracy: 0 of 5. This lesson's review cards are in your queue.

Practice

Put this lesson to work on the simulated cluster. Everything runs in your browser, with nothing to install.

Changed since the notes

This lesson draws on an earlier set of study notes. Where the documentation contradicts a claim in them, qualifies it or has moved past it, the claim is listed here with the corrected statement and the source it was checked against.

Show 4 corrections
  1. Stale, true once, no longerHealth Probes

    The notes said'the pod's IP is removed from Endpoint objects backing Services'

    CorrectedEndpointSlices (GA 1.21) are the source of truth for Service backends; kube-proxy and most controllers read them, and a not-ready pod is marked ready=false in its slice. The v1 Endpoints API is deprecated since 1.33 (still served, with warnings).

    Sourcekubernetes.io/blog/2025/04/24/endpoints-deprecation

  2. Stale, true once, no longerHealth Probes

    The notes saidProbe mechanisms limited to HTTP, TCP and exec ('Probes can check container health in three ways')

    CorrectedThere are four mechanisms: exec, grpc, httpGet and tcpSocket. gRPC probes (grpc.health.v1 Health/Check, port required, optional service) are GA since 1.27.

    Sourcekubernetes.io/docs/concepts/workloads/pods/probes

  3. Wrong, not trueHealth Probes

    The notes saidFor successThreshold 'For liveness probes, 1 is typical'

    CorrectedsuccessThreshold must be 1 for liveness and startup probes; validation rejects other values. Only readiness probes accept values above 1.

    Sourcekubernetes.io/docs/concepts/workloads/pods/probes

  4. Wrong, not trueHealth Probes

    The notes said'Startup probes run instead of liveness probes'

    CorrectedIf a startup probe is configured, the kubelet runs neither liveness nor readiness probes until it succeeds; after that both run normally. If it fails past failureThreshold the container is killed.

    Sourcekubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#startup-probe

Every correction across the guide, by note and topic.

Sources

Checked against kubernetes.io and AWS documentation for Kubernetes 1.37 on .

  1. kubernetes.io/docs/concepts/workloads/pods/probes
  2. kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes
  3. kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle
  4. kubernetes.io/docs/concepts/services-networking/endpoint-slices
  5. kubernetes.io/blog/2025/04/24/endpoints-deprecation
  6. kubernetes.io/docs/concepts/workloads/controllers/deployment
  7. kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1
  8. kubernetes.dev/resources/keps/2727
  9. github.com/grpc/grpc/blob/master/doc/health-checking.md

Probes: startup, readiness and liveness

↓ ↑ step, 1 to 7 scene, Esc leave

kind cluster kxLast command: Nothing run yet