Sub topic 14
Debugging failing probes
This chapter assumes you can apply manifests and read kubectl output. It also assumes you know what liveness, readiness, and startup probes do and which parameters control them. The goal is a repeatable way to find out why a probe fails.
Start with the symptom
The symptom tells you which probe is failing.
| Symptom | Likely probe | What to check |
|---|---|---|
| Pod is `Running` but `READY` shows `0/1` | Readiness | Probe path, port, and dependencies |
| `RESTARTS` count keeps rising | Liveness or startup | Timeouts, slow startup, hung process |
| `CrashLoopBackOff` | Liveness, startup, or the app itself | Previous container logs and exit code |
| Service returns errors, but Pods look healthy | Readiness too permissive | Endpoint membership |
Read the events
kubectl describe shows the probe configuration and the events the kubelet recorded. Failure messages are specific.
kubectl describe pod -l app=webLook for lines such as these in the Events section:
Readiness probe failed: HTTP probe failed with statuscode: 503means the app answered, but with a failing status.Liveness probe failed: Get "http://10.0.1.5:8080/healthz": context deadline exceededmeans the request exceededtimeoutSeconds.Startup probe failed: connection refusedmeans nothing is listening on that port yet, or the port is wrong.Container web failed liveness probe, will be restartedconfirms the kubelet is killing the container.
The Liveness:, Readiness:, and Startup: lines in the container section show the values in effect, including defaults you did not set. Compare them with what you intended.
Check traffic routing
A failing readiness probe removes the Pod's address from the Service's endpoints. Confirm this directly.
kubectl get endpointslices -l kubernetes.io/service-name=webIf a Pod's address is missing, its readiness probe is failing. If all addresses are missing, every Pod is failing readiness, often because a shared dependency is down. That is the case to think about before you change anything.
Read the logs, including the previous instance
After a restart, the current container's logs are often empty or only show startup. The logs that explain the failure belong to the previous instance.
kubectl logs deploy/web --previousCheck the exit code in kubectl describe under Last State. Exit code 137 means the container was killed by SIGKILL, which is what happens after a liveness failure when the process ignores SIGTERM past the grace period. Exit code 1 or 2 usually points to an application crash, not a probe.
Run the probe yourself
Reproduce what the kubelet does. For an HTTP probe, call the endpoint from inside the Pod.
kubectl exec deploy/web -- wget -qO- -T 2 http://localhost:8080/readyIf the image has no wget or curl, use kubectl port-forward and test from your machine. Note that a port-forward goes through the same container port, but it does not test the Pod IP the kubelet uses. If your app binds to 127.0.0.1 only, a local test passes and the kubelet probe fails with connection refused. Bind to 0.0.0.0.
Common causes
- The path or port in the probe does not match what the app serves.
timeoutSecondsis 1 by default, and the endpoint is slower under load.- The startup window is too short, so liveness restarts the app before it finishes starting. Add or extend a startup probe.
- The readiness endpoint checks a dependency that is down, so every Pod leaves the Service together.
- The app requires authentication or a redirect, and the probe sees a status outside 200–399.
A change to a probe in a Deployment's Pod template triggers a rollout. Watch it with kubectl rollout status deploy/web to confirm the new Pods become ready.
Exercise
A Pod shows READY 0/1 and zero restarts. kubectl describe reports "Readiness probe failed: connection refused". The app works when you call it through kubectl exec on localhost. What is the most likely cause, and what do you check next?
Show answer
The app is probably bound to 127.0.0.1 only, or the probe port does not match the port it listens on. The kubelet connects to the Pod IP, so a loopback-only listener refuses it. Check the app's bind address and compare the probe's port with the container port.