Forbidden: cannot list resource
The API server authenticated the caller but no RBAC binding allows this request. The message contains everything you need.
Read it
Section titled “Read it”| Part | Value in the example |
|---|---|
| Who | jane@example.com (a service account appears as system:serviceaccount:<ns>:<name>) |
| Verb | patch |
| Resource | deployments (subresources appear as pods/exec, pods/log) |
| API group | apps ("" means the core group: pods, services, secrets, configmaps) |
| Scope | namespace shop (no namespace means a cluster-scoped request) |
Diagnose
Section titled “Diagnose”- Confirm who the API server thinks you are:
kubectl auth whoami. - Test the exact request:
kubectl auth can-i patch deployments.apps -n shop --as=jane@example.com. - List what the identity can do:
kubectl auth can-i --list -n shop --as=jane@example.com.
Usual causes
Section titled “Usual causes”| Cause | Sign |
|---|---|
| No binding at all | can-i --list shows almost nothing |
| Binding in a different namespace | Works in one namespace, forbidden in another |
| Subject spelled differently | The binding names jane but the identity provider sends jane@example.com, or a group the token doesn’t carry |
| Role missing the verb or subresource | get pods allowed but pods/log or pods/exec isn’t |
Grant the smallest Role that covers the verb, resource, and namespace in the message, bound to the exact subject. Avoid fixing it with a ClusterRoleBinding to a broad role.
Read next: RBAC and service accounts.