The Linkerd proxy detects the protocol from the client's first bytes. If the server speaks first – as with SMTP or MySQL – client and proxy wait for each other until the proxy gives up after ten seconds.
Symptom
kubectl -n tag16 exec deploy/last -c last -- sh -c 's=$(date +%s); (sleep 15) \ | nc banner 2525 | while read l; do echo "$(( $(date +%s) - s )) s: $l"; done' 10 s: 220 banner bereit
The server's greeting arrives after exactly ten seconds. Port 2525 is not on Linkerd's opaque list.
Diagnosis
Search the client's proxy log for the timeout. linkerd diagnostics policy with a Service shows the outbound view: protocol Detect with a ten-second deadline.
kubectl -n tag16 logs deploy/last -c linkerd-proxy --since=1m | grep 'after timeout'
linkerd diagnostics policy -n tag16 svc/banner 2525 -o json \
| jq -c '.protocol.Kind | keys, .Detect.timeout'
INFO ThreadId(01) outbound:proxy{addr=10.99.111.91:2525}: linkerd_app_outbound::pro...
...tocol: Continuing after timeout: 10s
["Detect"]
{"seconds":10}
Causes
Server speaks firstProtocol detection without client bytes
The client proxy waits for the client's first bytes, the client waits for the server. Only after the timeout does the proxy forward the connection.
PortPort not on the opaque list
Linkerd has a default list of opaque ports (25, 587, 3306, …). A service on another port – here 2525 – goes through protocol detection.
Fix
kubectl -n tag16 annotate service banner config.linkerd.io/opaque-ports=2525 linkerd diagnostics policy -n tag16 svc/banner 2525 -o json \ | jq -c '.protocol.Kind | keys' ["Opaque"] 0 s: 220 banner bereit
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
What does the warning "opaque ports are properly annotated" mean?
The Service declares a port opaque, but the pod behind it doesn't. Also set the config.linkerd.io/opaque-ports annotation on the pod template.
Does it work without an annotation?
On the Service, yes – with appProtocol linkerd.io/opaque on the port.
Does the annotation on the pod extend the default list?
No. config.linkerd.io/opaque-ports on the workload replaces the default list for this pod.