The database is gone and the pods do not become ready – that is correct. But the probe does not report a 503, it reports a timeout. It gives up before the service can finish its own database check.
Symptom
kubectl -n kurz get endpointslices -l kubernetes.io/service-name=kurz \
-o jsonpath='{range .items[*].endpoints[*]}{.addresses[0]} ready={.conditions.ready}{"\n"}{end}'
kubectl -n kurz get events --field-selector reason=Unhealthy -o custom-columns=MELDUNG:.message --no-headers | tail -2
10.42.4.4 ready=false
10.42.2.8 ready=false
Readiness probe failed: Get "http://10.42.4.4:8080/readyz": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
The endpoints stay in the EndpointSlice, but with ready=false. The service has no ready endpoints left.
Diagnosis
Read the readiness probe in the manifest. Without timeoutSeconds the default of one second applies.
grep -A6 readinessProbe kurz.yaml
Causes
timeoutSeconds 1Probe as short as the check behind it
/readyz gives the database one second internally. The probe's timeoutSeconds is at the default, also one second. The probe aborts before the answer arrives.
same result, wrong messageTimeout instead of 503
The pod does not become ready either way. But anyone hunting for a network problem because the message talks about a timeout is looking in the wrong place.
Fix
grep -A6 readinessProbe kurz.yaml
readinessProbe:
httpGet:
path: /readyz
port: http
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 2
kubectl apply -f kurz.yaml
Don't: Put the database check into the liveness probe. A restart does not fix a missing database – liveness asks /healthz, readiness /readyz.
System design on Kubernetes, Day 1: kurz as a deployment – probes, service, CloudNativePG and a database in hibernation.
Go to day 1 →
FAQ
Why does RESTARTS stay at 0 although the database is missing?
The liveness probe asks /healthz, which does not depend on the database. The kubelet has no reason to restart – and that is correct.
How long until a pod is no longer ready?
periodSeconds times failureThreshold – in the course 5 s × 2 = 10 seconds.