Learning center

Verify which Kubernetes service account a failing pod uses

Inspect the running pod's service account when a workload reports a Kubernetes API 403. The intended account in a deployment template may differ from the account used by a pod that still runs from an earlier revision.

Suppose a fictional worker should use report-reader, but the audit record names system:serviceaccount:jobs:default. Read the assigned account from the affected pod.

kubectl get pod report-worker-7d46d -n jobs \
  -o jsonpath='{.spec.serviceAccountName}{"\n"}'

If the pod uses default and the deployment should use report-reader, route the configuration mismatch to the workload owner. Keep grants on the dedicated account. If the pod already lists report-reader, check whether this client uses a separate kubeconfig or other credentials, and match the audit event to the specific pod. The Pod spec identifies the assigned service account. The API event identifies the credentials used for that request. Kubernetes service accounts ยท Assign a service account to a pod

Trace another denied request.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading