If a Service has no ready endpoints, the client's Linkerd proxy waits three seconds and then answers with 503 itself (fail-fast). The pods can be perfectly healthy – it is enough that the Service no longer finds them.
Symptom
kubectl -n tag16 logs deploy/last -c last --since=40s | awk '{print $2, $3}' \
| sort | uniq -c
58 /api/notes 200
29 /flaky 503
Only the path to one service returns 503, everything else works. The target pod is ready.
Diagnosis
linkerd diagnostics endpoints shows what linkerd-destination hands out to the proxies. The EndpointSlice next to it has no ports.
linkerd diagnostics endpoints helper.tag16.svc.cluster.local:80 kubectl -n tag16 get endpointslices -l kubernetes.io/service-name=helper No endpoints found. NAME ADDRESSTYPE PORTS ENDPOINTS AGE helper-jcdjm IPv4 <unset> 10.0.1.106 60s
Causes
Port nametargetPort points to a name that no longer exists
The container port was renamed from http to web, the Service still looks for targetPort: http. The proxy log at debug level shows "No ready endpoints".
kubectl -n tag16 logs deploy/web -c linkerd-proxy --since=30s \
| grep -oE 'name=helper port=80\}:pool: .*' | cut -c1-80 | sort | uniq -c \
| sort -rn | head -4
21 name=helper port=80}:pool: linkerd_pool_p2c: No ready endpointsNot readyNo ready pod behind the Service
If the pod is stuck, for example in an init container's backoff, there is no ready endpoint. Then too, the client's proxy answers with 503 after three seconds.
Fix
kubectl -n tag16 patch deploy helper --type=json -p '[
{"op":"replace","path":"/spec/template/spec/containers/0/ports/0/name",
"value":"http"},
{"op":"replace",
"path":"/spec/template/spec/containers/0/readinessProbe/httpGet/port",
"value":"http"}]'
kubectl -n tag16 rollout status deploy/helper --timeout=120s
P=$(kubectl -n tag16 get pod -l app=helper -o name)
linkerd diagnostics policy -n tag16 $P 8080 -o json | jq -c '{server: .labels.name}'
{"server":"helper-http"}
Linkerd hands-on, day 16: build in eight typical mesh faults, find them with linkerd check and diagnostics, and fix them.
Go to day 16 →
FAQ
Why do I get 403 after only updating the Service?
The Linkerd Server also looks for the old port name. The port then falls under the default policy – diagnostics policy shows server deny.
Where does the 503 come from if the target pod is running?
From the client's proxy. If it finds no ready endpoints, it answers with 503 itself after three seconds.
How do I get more detail out of the proxy?
With the config.linkerd.io/proxy-log-level annotation on the pod template, e.g. warn,linkerd=debug. It only takes effect after a restart and produces a lot of text – use it only briefly.