PREP WITH PROOF
Menu
KUBERNETES & DEVOPS / PRACTICAL GUIDE

Kubernetes Readiness vs Liveness vs Startup Probes

Choose Kubernetes health probes with a practical YAML example, dependency-failure decisions, timing guidance, and a restart-loop troubleshooting workflow.

THE QUICK ANSWER

Use readiness to decide whether a container can serve traffic, liveness to detect a failure that warrants restarting it, and startup to protect initialization. A failed readiness check does not restart the container. A configured startup probe holds back both other probes until it succeeds. Design each check around the recovery action you actually want.

Start with the action a failed check should cause

A running Pod can still be unable to serve a useful response. Imagine an orders API whose process is alive while its worker pool is stuck. Now imagine the same API waiting for a briefly unavailable database. Both cases can produce failed requests, but restarting the API is a different decision in each case. A health endpoint that collapses both conditions into one answer leaves that decision to an overly broad check.

Kubernetes runs container probes through the kubelet. Readiness affects eligibility for ordinary Service traffic; liveness and startup failures can cause the affected container to be killed and handled under its restart policy. This guide uses a Deployment, whose containers normally restart. A container restart is not the same operation as deleting and recreating the whole Pod.

Before editing YAML, write one sentence for each failure: “This instance should stop receiving requests,” “This process needs a restart,” or “Initialization still needs time.” If you cannot explain why a restart would help, investigate the health contract before adding a liveness check. The goal is a predictable response to a failure, not three green indicators.

ProbeQuestion it answersResponse after the failure threshold
ReadinessCan this instance serve its intended traffic now?Marks the container unready; no probe-triggered restart.
LivenessWould restarting this unhealthy process help?Kills the affected container; restart policy applies.
StartupHas this container completed the startup check?Blocks other probes until success; persistent failure kills the container.

Source: Kubernetes: liveness, readiness, and startup probe concepts ↗

Give health endpoints explicit contracts

For an example HTTP API, define /livez as a cheap local progress check, /readyz as permission to accept the requests this instance is responsible for, and /startupz as completion of essential initialization. These paths are illustrative application interfaces. Kubernetes does not create them for your application. Your code must implement them, and the behavior must be documented alongside the deployment configuration.

Consider an optional recommendation service used on an order page. An editorial design choice for this example is to keep the orders API ready while returning the page without recommendations. If every readiness check calls that optional service and fails when it is slow, an optional feature can take the entire API out of service. Decide which degraded responses remain useful before wiring dependencies into readiness.

For a required database, ask whether the failure is local to one instance or shared by all replicas. Withdrawing one instance with a broken connection pool might help; withdrawing every instance during a shared database outage changes the user-visible failure and does not repair the database. Define that tradeoff deliberately. Keep dependency checks bounded and consider maintaining a recent dependency-health state rather than opening a fresh expensive connection on every probe.

Avoid making the probe perform a business operation such as placing an order or writing a row. It should be safe to repeat and should not expose credentials, customer information, or detailed infrastructure diagnostics in its response. Also make sure a separate health listener can detect failure in the actual request-processing path; a healthy management thread is weak evidence if the request workers are permanently stuck.

Source: Kubernetes: liveness, readiness, and startup probe concepts ↗

An example container configuration to adapt

The following is a container fragment for an existing Deployment, under spec.template.spec.containers. It is not a complete manifest or a runnable application. Retain your own container image and environment settings, and implement all three endpoint contracts before applying these fields. The numbers are an illustrative starting point for a lab, not recommended defaults for every service.

The startup settings allocate a nominal 150-second failure budget from 30 attempts spaced five seconds apart. Use that multiplication as planning guidance, not a promise of an exact wall-clock restart time. Probe scheduling, timeout behavior, and termination handling matter. Choose the actual budget from observed slow starts, including realistic initialization work, and leave an intentional margin.

After startup succeeds, this example checks readiness more frequently than liveness and requires two consecutive readiness successes to recover from a failed state. Liveness and startup successThreshold must be one. timeoutSeconds limits an individual attempt; periodSeconds controls its cadence; failureThreshold controls consecutive failures. Raising a timeout cannot repair a wrong path or a missing endpoint.

# Container fragment: keep your real image and other settings.
- name: api
  ports:
    - name: http
      containerPort: 8080
  startupProbe:
    httpGet:
      path: /startupz
      port: http
    periodSeconds: 5
    timeoutSeconds: 2
    failureThreshold: 30
    successThreshold: 1
  readinessProbe:
    httpGet:
      path: /readyz
      port: http
    periodSeconds: 5
    timeoutSeconds: 2
    failureThreshold: 3
    successThreshold: 2
  livenessProbe:
    httpGet:
      path: /livez
      port: http
    periodSeconds: 10
    timeoutSeconds: 2
    failureThreshold: 3
    successThreshold: 1

Source: Kubernetes: configure liveness, readiness, and startup probes ↗

Test three different failures in a disposable environment

Treat the following as a proposed validation workflow, not a claim that this application has been deployed or benchmarked. Use an isolated test namespace and a service you control. Add explicit test-only switches for initialization delay, readiness failure, and a simulated local progress failure. Do not expose those controls on a public production endpoint.

First, delay initialization for less than the startup budget. Observe that the container remains outside normal traffic while it starts, then becomes ready after its readiness checks succeed. Repeat with initialization that never finishes. The second case should exercise the failure response rather than silently leave the deployment appearing healthy. Capture the actual timeline instead of concluding that the configured arithmetic guarantees an exact duration.

Second, force only readiness to fail after startup. Compare the ready condition, restart count, and observed Service behavior before and after the change. Restore readiness and watch recovery. A growing restart count means you need to identify another cause; it is not the expected direct action of a readiness failure. Keep application logs from both sides of the transition.

Third, simulate the local condition that your liveness endpoint is designed to detect. Confirm that a restart clears that specific condition and the instance returns through its startup and readiness checks. A test that merely returns HTTP 500 proves probe wiring, but it does not establish that your check detects a real deadlock. Document separately what was simulated and what remains untested.

For each exercise, save a small record with the injected condition, expected action, actual events, restart count, and recovery result. An unexplained mismatch is a reason to revise the configuration or endpoint implementation. This record is more useful during a later incident than a screenshot showing that the Pod was green at one moment.

Diagnose a failing probe before changing its thresholds

Begin by naming the namespace, Pod, and container. The example commands below use checkout-demo, api-example, and api as placeholders that you must replace. They inspect state and logs; they do not change the deployment. In a multi-container Pod, selecting the container explicitly prevents you from reading a healthy sidecar’s logs while the application is failing.

Read the events in describe output, then compare them with current and previous container logs. The --previous flag retrieves logs from the previous terminated instance when those logs are available. It is useful after a restart, but it is not an archive of every past container instance. Preserve relevant output before repeated failures make the timeline harder to reconstruct.

Classify the symptom before fixing it. For connection refusal, investigate the listening address, port, and whether the application has begun listening. For an HTTP error, investigate the endpoint implementation and application logs. For a timeout, compare endpoint latency with resource pressure and downstream waits. A probe error is evidence about the check; it is not by itself proof of the underlying cause.

Also inspect termination reasons and exit codes. A process crash, memory-related termination, and a probe-triggered termination call for different investigations. “The container restarted” is an observation, not a diagnosis. If the timeline does not connect a probe failure to the restart, avoid changing probe thresholds merely because they are easy to edit.

kubectl get pod api-example -n checkout-demo -o wide
kubectl describe pod api-example -n checkout-demo
kubectl logs api-example -n checkout-demo -c api --tail=100
kubectl logs api-example -n checkout-demo -c api --previous --tail=100

Source: Kubernetes: debug running Pods ↗

Check the Service path as well as the probe result

For a selector-based Service, verify that its selector matches the intended Pods and inspect its EndpointSlices. A successful readiness response is not enough to prove that a client can reach the application through the intended Service port. Keep separate notes for container health, endpoint selection, and an actual client request.

The commands below inspect the Service and the EndpointSlices associated with it. Replace orders-api and the namespace with real values. Compare the selector, target port, endpoint addresses, and readiness conditions. Services without selectors and alternative routing arrangements require their own investigation; do not assume this exact selector-based workflow applies to every networking design.

Test with the same route that users or upstream services actually take. A successful direct Pod request and a failed Service request give you a different investigation from both failing. Readiness is also not a firewall or a guarantee that every existing connection has drained. Custom consumers and Service options can change how endpoint readiness is used.

kubectl get service orders-api -n checkout-demo -o yaml
kubectl get endpointslices -n checkout-demo \
  -l kubernetes.io/service-name=orders-api -o yaml

Source: Kubernetes: Services ↗

Choose thresholds from recovery evidence

Before rolling a probe change out, decide which failure the change is supposed to improve. If the problem is a slow but successful initialization, validate the startup budget against slow starts. If the problem is temporary loss of readiness, measure how long withdrawal and recovery take. If the problem is a stuck process, demonstrate that the chosen liveness signal identifies it and that restarting helps.

Change one part of the contract at a time where practical. Editing endpoint logic, timeouts, and all three failure thresholds in one release makes a better result difficult to explain. Keep the previous configuration available for rollback and compare application errors, latency, and restart counts around the rollout. A quieter probe graph does not establish that customer requests are succeeding.

The durable outcome is a health contract your team can explain: what each endpoint observes, what failure response follows, how recovery was checked, and which limitations remain. Revisit it when initialization work, required dependencies, or traffic patterns change. Start with the smallest check that answers the relevant operational question, then validate its consequences before broadening it.

KEEP THESE THREE THINGS

Your next steps

  1. Write separate traffic, restart, and startup contracts before copying probe YAML.
  2. Exercise delayed startup, readiness loss, and a recoverable local failure; record the observed action for each.
  3. Investigate events, termination reasons, logs, and Service endpoints before relaxing thresholds.

Sources & official resources

Linked resources checked on 2026-10-22. Technical behavior and provider guidance can change; check the documentation for the version you use.

About this guide and its recommendations

Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.

Suggest a correction →