Readiness probe

What it is

A readiness probe checks whether a running application instance
should receive traffic. In Kubernetes, the kubelet runs the
configured probe against a container. A failed readiness probe marks
that container unready. The Pod's readiness can then affect whether
matching Services use it as a ready endpoint. The process can remain
running while the platform stops directing ordinary requests to it.

The probe can make an HTTP request, try to open a socket, use a gRPC
health check, or run a command according to the configuration. A
simple socket test answers whether a listener can accept a
connection. An application-level check can answer a more specific
question, such as whether the service loaded its configuration and
can respond to the traffic that instance will receive. Choose an
observable condition with a useful relationship to the actual
request path.

Readiness can change throughout a Pod's lifetime. An application may
come up, prepare its local state and become ready, then temporarily
become unready while it recovers from a failure. Kubernetes also has
liveness probes, which can lead to restarts after failure, and
startup probes, which can give a slow startup time before other
probes run. Those controls take different actions. Give each a clear
reason for its result and review their timing together.

Why it matters

A server may bind its port before it can answer useful requests. It
could still be loading a routing table, opening a local data store
or checking that its configuration is usable. Directing traffic to
the server at that point can turn an ordinary deployment into a wave
of failures. A readiness condition lets the application explain when
it can take requests while deployment and networking continue
independently.

Readiness also helps with partial failures. Consider three instances
of a service. One loses access to a resource needed for its main
requests while the other instances continue. A local readiness
signal can steer new requests toward the instances that can still
serve them. The user-facing benefit comes from detecting the failure
promptly and preserving enough capacity elsewhere. Both the timing
and the availability of those other instances belong in the design.

Shared dependencies need a deliberate policy. If every instance
checks an optional service and withdraws whenever that service is
slow, a small outage can remove the whole application from routing.
Decide which requests remain meaningful with a fallback, and which
must fail closed when a critical dependency is missing. The probe
itself should be bounded and cheap enough to run regularly under
load. Measure the result the platform observes as well as the result
returned by the probe.

What it looks like in practice

Imagine an API with a startup phase that prepares an in-memory
index. Its normal health endpoint can prove that the process
responds. Its readiness endpoint can report success once the
instance can serve the index-backed request. A replacement Pod
starts with readiness false, prepares the index, and then becomes
eligible for traffic. A rollout test can verify the order by
following the Pod status, the Service endpoints and a request that
actually queries the index.

Test failure as well as startup. Force one instance to lose the
resource it checks, confirm the endpoint becomes unready and watch
which instance receives the next request. Keep a client connected
during the change. A readiness transition affects how traffic is
selected, yet existing connections and other load balancers have
their own timing. Observe them explicitly. On shutdown, stop
accepting new work and give in-progress requests a bounded chance to
finish before the process exits.

Engineer's Azure platform deployment case study documents promoting
the same artefact through development, staging and production with
environment-specific settings. That discipline matters when tuning
an admission check. An illustrative service can exercise the same
health condition in staging and production and supply its real
dependencies through configuration. The release check should confirm
that the instance becomes ready for the expected reason in each
environment.

Where it goes wrong

A readiness endpoint that returns success whenever the process can
answer it can give a false sense of availability. Put the minimum
required state into the signal. Keep the response designed for
operators, and avoid expensive work or sensitive dependency details.
A failed probe should be traceable from the Pod condition to a
useful application log, so the team can tell whether to wait or
repair configuration.

Timeouts and thresholds can work against the desired outcome. If a
first failure may be transient, consecutive observations can reduce
flapping. A long period before noticing repeated failure can send
traffic to an instance that has already stopped serving correctly.
Model recovery and failure separately. Test the observed time from a
degraded dependency to endpoint withdrawal, and from recovery to a
useful successful request. Calculate the total time using the
platform's actual scheduling and retry settings.

Test delivery of the status at the actual boundary too. An
orchestrator can observe a local probe result before another traffic
component has applied the corresponding endpoint update. A
connection reused by a client can survive several rounds of endpoint
changes. Correlate the probe timestamp with the first real request
that moves away from the instance. This measurement gives a release
an observed response time for admission changes, which is more
useful than adding up timers from separate configuration files.

Lastly, separate service admission from capacity guarantees. A green
ready count describes how many instances pass the configured probe.
A useful load test checks how much work they can sustain, which
requests succeed and how responses change as one instance leaves.
Keep an operator's procedure for checking real endpoints during a
rollout, especially where more than one traffic layer is involved.
The probe is most valuable when its result explains a measured
change in the service a client receives.

Further reading

  * Kubernetes container probes. Explains when readiness fails and
how probe types affect a container.

  * Configuring liveness, readiness and startup probes. Gives
concrete Kubernetes configuration examples.

  * Kubernetes EndpointSlices. Describes the endpoint conditions
exposed to Service consumers.

hThis page on the web	URL:https://engineer.company/glossary/readiness-probe/	engineer.company	70
