Skip to content

Linkerd 403 "Request denied": default deny or wrong identity

Linkerdtested on Linkerd edge-26.11.2

With the default policy deny, the Linkerd proxy only lets through what a Server and an AuthorizationPolicy allow. Rejected requests end with 403 and a "Request denied" line in the target's proxy log. The server name and client identity in it show the cause.

Symptom

kubectl -n tag16 logs deploy/last -c last --since=20s | awk '{print $2, $3}' \
  | sort | uniq -c
     30 /api/notes 403
     14 /flaky 403

linkerd viz often doesn't help here: viz reads Prometheus, and its scrapes on port 4191 are rejected too. linkerd viz tap does not show rejected requests – they end before the point where tap listens in.

Diagnosis

Go straight to the proxy: the log names the server and client TLS, linkerd diagnostics policy shows which Server and which rules apply to the port.

kubectl -n tag16 logs deploy/web -c linkerd-proxy --since=1m \
  | grep 'Request denied' | grep -v admin | tail -1 \
  | grep -oE 'server.name=[^ ]*|client.tls=[^ ]*'
P=$(kubectl -n tag16 get pod -l app=web -o name)
linkerd diagnostics policy -n tag16 $P 8080 -o json \
  | jq -c '{server: .labels.name, authz: .authorizations}'
server.name=deny
client.tls=Some(Established
{"server":"deny","authz":null}

Causes

Everything 403Default deny without Servers and rules

server.name=deny means: no Server matches, the default policy applies, and it contains not a single authorization. That hits Postgres too – migrate fails with Init:Error.

One client 403Wrong ServiceAccount

A proxy's identity is its ServiceAccount. Without serviceAccountName the pod speaks as default – but the MeshTLSAuthentication expects a different name.

linkerd viz edges -n tag16 deploy -o wide
SRC    DST   SRC_NS   DST_NS   CLIENT_ID       SERVER_ID   SECURED
last   web   tag16    tag16    default.tag16   web.tag16   √
kubectl -n tag16 logs deploy/web -c linkerd-proxy --since=1m \
  | grep -m1 'Request denied' | grep -oE 'server.name=[^ ]*|Name\("[^"]*'
kubectl -n tag16 get meshtlsauthentication last -o jsonpath='{.spec}{"\n"}'
server.name=web-http
Name("default.tag16.serviceaccount.identity.linkerd.cluster.local
{"identityRefs":[{"kind":"ServiceAccount","name":"last"}]}

TypoMeshTLSAuthentication doesn't match

You get the same picture with a typo in the MeshTLSAuthentication or a ServiceAccount from a different namespace.

Fix

If rules are missing, create Servers and AuthorizationPolicies. If the identity is wrong, set the correct ServiceAccount.
kubectl -n tag16 set serviceaccount deploy/last last
kubectl -n tag16 rollout status deploy/last --timeout=120s
kubectl -n tag16 logs deploy/last -c last --since=40s | awk '{print $2, $3}' \
  | sort | uniq -c
     54 /api/notes 200
     21 /flaky 200
      6 /flaky 500
▶
Break it yourself and find it – free
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

How do I test a rule from the point of view of a specific client?

With an ephemeral container via kubectl debug. It shares the pod's network and proxy and therefore speaks with its identity.

Why doesn't linkerd viz tap show the 403s?

Rejected requests end before the point where tap listens in. For 403s, the proxy log and linkerd viz authz are the tools.

Related error patterns

More