Sub topic 7
Readiness probes and which Pods receive traffic
This chapter assumes you can apply YAML with kubectl, know what a Deployment and a Pod are, and have read the previous chapter on how a Service selector becomes EndpointSlices. A Service selects Pods by label. Readiness decides which of those selected Pods actually get traffic.
Selected is not the same as ready
The Service selector matches every Pod with the label app=web. The EndpointSlice controller then lists those Pods, but each endpoint carries a ready condition. kube-proxy and CoreDNS only send traffic to endpoints whose ready condition is true.
A Pod's ready condition comes from its readiness probe. The kubelet runs the probe on a schedule. While the probe fails, the Pod stays in the EndpointSlice with ready: false. It receives no new connections from the Service. It is not restarted. That is the key difference from a liveness probe, which restarts the container on failure.
The probe in the Deployment
The web Deployment from earlier already has a readiness probe:
readinessProbe:
httpGet:
path: /
port: httpThe kubelet sends GET / to the container port named http. A response status from 200 to 399 counts as success. Any other status, or no response, counts as failure.
You can tune the timing with these fields:
| Field | Default | Meaning |
|---|---|---|
| `initialDelaySeconds` | 0 | Wait before the first probe |
| `periodSeconds` | 10 | Time between probes |
| `failureThreshold` | 3 | Consecutive failures before the Pod becomes not ready |
| `successThreshold` | 1 | Consecutive successes before it becomes ready |
The flow
Watching it happen
Break the probe on purpose. Change the path to one that does not exist, then watch the rollout and the EndpointSlice:
kubectl set probe deployment/web --readiness --get-url=http://:http/missing
kubectl get pods -l app=web
kubectl get endpointslices -l kubernetes.io/service-name=web -o yamlIf your kubectl version has no set probe, edit the manifest and run kubectl apply. The new Pods show 0/1 under READY. Because a Deployment rolling update waits for new Pods to become ready, the old Pods keep serving. The rollout stalls instead of taking the site down.
Common errors
- A Pod is Running but gets no traffic. Running only means the container started. Check the READY column and the endpoint's
readyfield. - A probe that checks too much. If the probe calls a shared database and the database fails, every Pod becomes not ready at once, and the Service has no endpoints. Probe only what this Pod needs to serve requests.
- A wrong probe port or path. The Pod never becomes ready, and
kubectl describe podshowsReadiness probe failedevents. - Slow start with no delay. An app that needs 30 seconds to start fails early probes. This is harmless for traffic, but it can slow a rollout. Use a
startupProbefor very slow apps.
Exercise
A Deployment has three Pods. One Pod's readiness probe starts failing. What happens to the Pod, and to Service traffic?
Show answer
The Pod is not restarted and is not deleted. Its endpoint in the EndpointSlice is marked ready: false, so kube-proxy and DNS stop sending new connections to it. The other two Pods keep receiving traffic. When the probe succeeds again, the endpoint becomes ready and the Pod rejoins.