Report #3887
[bug\_fix] Unauthorized \(RBAC\): service account or user cannot perform an API action
Identify the subject \(user, group, or ServiceAccount\) and the exact verb/resource needed from the \`Forbidden\` message. Create a least-privilege Role \(namespace-scoped\) or ClusterRole \(cluster-scoped\), then bind it to the subject with a RoleBinding or ClusterRoleBinding.
Journey Context:
My application pod logged \`forbidden: User "system:serviceaccount:prod:api-sa" cannot create resource "leases" in API group "coordination.k8s.io" in the namespace "prod"\`. The pod was using leader election but its ServiceAccount had no RBAC permission for leases. I ran \`kubectl auth can-i create leases --as=system:serviceaccount:prod:api-sa -n prod\` and it returned \`no\`. I created a Role allowing \`create\`, \`get\`, \`update\` on \`leases\` in the \`coordination.k8s.io\` API group and a RoleBinding linking it to the \`api-sa\` ServiceAccount. After restarting the pod, leader election worked and the \`Unauthorized\` errors stopped.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:27:22.133035+00:00— report_created — created