Sub topic 2
The kubelet runs the probes
This chapter assumes you know Pods, Deployments, and Services, can read YAML, and can use kubectl describe. It explains who runs probes and what happens with the results. The probe types and timing fields come in later chapters.
Who does the probing
The kubelet is the agent that runs on every node and manages the containers of the Pods scheduled there. It also runs the probes. The API server, the scheduler, and the Service machinery never probe your containers.
Three consequences follow from this:
- Probes run from the node that hosts the Pod. An
httpGetprobe sends its request from the node to the Pod IP, not from another Pod or from a load balancer. - Each container probe is checked independently. A Pod with a startup, liveness, and readiness probe on one container has three separate checks running on their own timers.
- Probing needs a working kubelet. If the kubelet stops, no probes run and nothing acts on probe results on that node.
What the kubelet does with a result
Each check ends as success or failure. The kubelet counts consecutive results against the configured thresholds. It acts only when a threshold is crossed, so one failed check rarely causes anything to happen.
What the kubelet does next depends on the probe type:
| Probe | Action when it crosses its failure threshold |
|---|---|
| Startup | Kills the container, subject to the restart policy |
| Liveness | Kills the container, subject to the restart policy |
| Readiness | Sets the Pod's `Ready` condition to false. The container keeps running. |
While a startup probe is configured and has not yet succeeded, the kubelet does not run the liveness and readiness probes.
The kubelet does not edit Services. It reports the Pod's Ready condition to the API server. The EndpointSlice controller watches that condition and adds or removes the Pod's address from the Service's endpoints. Traffic stops reaching the Pod a short time after the readiness probe fails, because several components must each notice the change.
Starting values
Before the first probe result arrives, the kubelet assumes a default for each probe type:
- Readiness starts as failed. A Pod with a readiness probe is not in the endpoints until the first check passes.
- Liveness starts as successful, so a container is not killed before its first check.
- With no readiness probe, a running container counts as ready immediately.
Seeing the kubelet's decisions
The kubelet records probe failures as Pod events, and kubectl describe shows them.
kubectl describe pod -l app=web
kubectl get endpointslices -l kubernetes.io/service-name=web
kubectl logs deploy/web --previousLook for Unhealthy events, such as Readiness probe failed or Liveness probe failed. After a liveness failure you will also see a Killing event, and the restart count in kubectl get pods increases. The --previous flag prints the logs of the container instance that was killed.
Exercise
A container's readiness probe starts failing, but its liveness probe still passes. Which component removes the Pod from the Service's endpoints, and does the container restart?
Show answer
The kubelet marks the Pod's Ready condition false and reports it to the API server. The EndpointSlice controller then removes the Pod's address from the Service's endpoints. The container does not restart, because only a failing liveness or startup probe causes the kubelet to kill it.