Designing a Kubernetes readiness probe: mark only traffic-ready Pods as ready
A Kubernetes readiness probe periodically checks whether a container can handle requests now. On failure, Kubernetes does not restart the container; it marks the Pod unready and removes its IP from matching Service EndpointSlices. Use a startup probe for lengthy initialization, and design liveness separately to detect unrecoverable hangs.
A Kubernetes readiness probe periodically checks whether a container can handle requests now. On failure, Kubernetes does not restart the container; it marks the Pod unready and removes its IP from matching Service EndpointSlices. Use a startup probe for lengthy initialization, and design liveness separately to detect unrecoverable hangs.
Readiness, liveness, and startup have different jobs
| Probe | Question | Failure action |
|---|---|---|
| Readiness | Can this container accept normal traffic now? | Keep the container running, mark the Pod unready, and remove it from Service traffic |
| Liveness | Is the process stuck in an unrecoverable state? | After the configured consecutive failures, kubelet restarts the container |
| Startup | Has initialization finished so normal checks may begin? | Delay readiness and liveness until success; restart after exceeding the failure limit |
Readiness fits a state that is alive but should not receive traffic, such as loading files, warming caches, temporary overload, or recovery. It may check required backend dependencies, but define failure scope carefully so one external outage does not withdraw every replica at once. Liveness should check only a condition a restart can actually recover, such as a deadlock. A poorly designed liveness probe can repeatedly restart containers under load and cause cascading failures.
Probe mechanisms and conditions
The kubelet runs code inside the container or makes a network request. Each probe selects one mechanism:
`httpGet`: GET a path on the Pod IP and port. Status codes from 200 through 399 count as success. Use a small, dedicated endpoint; response-body content is not the success criterion.
`tcpSocket`: check whether the Pod IP and port accept a connection. This confirms only that a port is open, not that the application can serve requests correctly.
`grpc`: for apps implementing the gRPC Health Checking Protocol. The Kubernetes documentation marks gRPC probes stable since v1.27; success requires `SERVING`. Named ports are unsupported, and configuration errors count as failures.
`exec`: run a command in the container; exit code 0 means success. Each execution creates a process, which can add CPU overhead on dense nodes when run frequently.
Avoid making an HTTP probe depend on external authentication or expensive business operations. The readiness endpoint should fail only when the Pod cannot actually serve traffic. Add logs and metrics so probe results can be compared with Pod Ready and EndpointSlice state.
Set thresholds and startup time
Key defaults are periodSeconds: 10, timeoutSeconds: 1, failureThreshold: 3, and successThreshold: 1. Readiness may require consecutive successes to become ready again after failure. Liveness and startup require successThreshold to be 1. Tune checks to their cost and detection goal; a very short period or timeout can create failures during transient load.
When a startup probe is configured, kubelet does not run readiness or liveness until it succeeds. The startup window is approximately failureThreshold × periodSeconds; for example, 30 failures at 10 seconds gives about 300 seconds. Probe scheduling and timeouts affect actual timing, so leave operational margin. A startup probe separates initialization allowance from later liveness recovery.
Illustrative HTTP example (assumes the app serves /healthz and /ready on port 8080):
containers:
- name: api
ports:
- name: http
containerPort: 8080
startupProbe:
httpGet:
path: /healthz
port: http
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet:
path: /healthz
port: http
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: http
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 2This is a format example, not a configuration tested for a particular application. It illustrates separating “can the process keep progressing?” from “can this Pod accept traffic now?” Implement each endpoint to match the application's failure model.
Verify changes and recover from false positives
Document the exact conditions that fail readiness and those that justify a liveness restart.
Calculate the startup window from expected worst-case initialization plus margin; remember that startup delays readiness and liveness.
Roll out to a small scope and watch readiness failures, Pod Ready transitions, EndpointSlice targets, restart counts, and application logs.
Confirm readiness failure leaves the container running but removes traffic, while startup/liveness failures trigger the configured restart behavior. This article does not claim to have tested a live cluster.
If checks fail unexpectedly, pause or roll back the rollout and review timeout, period, thresholds, endpoint cost, and dependencies. Do not treat repeated restarts as a safe substitute for diagnosing the check.
Sources and scope
Kubernetes, [Liveness, Readiness, and Startup Probes](https://kubernetes.io/docs/concepts/workloads/pods/probes/)
Kubernetes, [Configure Liveness, Readiness and Startup Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)
Based on official Kubernetes documentation reviewed on 2026-11-19. Covers probe purposes, handlers, key thresholds, and behavior. No cluster configuration or application endpoint implementation was verified.