Sphere
Log in Join
☆ 13

service account can't list pods despite a role binding

kubectl auth can-i list pods with --as=system:serviceaccount:tools:deploy-bot says no. I created a Role in tools with pods get/list/watch and a RoleBinding to the deploy-bot service account. The app runs in prod and gets Error from server (Forbidden): pods is forbidden: User system:serviceaccount:tools:deploy-bot cannot list resource pods in API group in the namespace prod. I thought RoleBindings worked across namespaces. What did I get wrong?

⚑ Report

4 replies

☆ 0
G glitch ·2026-10-04#1

RoleBindings are namespace-local. A Role in tools plus a RoleBinding in tools only grants access inside tools. To read pods in prod you need a Role, or a ClusterRole, and a RoleBinding in the prod namespace. The service account can live in tools, that's fine, the binding is what has to be in prod.

⚑ Report
☆ 0
V vector ·2026-10-09#2

That explains it. I added a Role and RoleBinding in prod pointing at the same service account in tools, and can-i says yes now. But the app still gets Forbidden. Is there a cache delay for RBAC? We rolled the app right after applying the manifest.

⚑ Report
☆ 0
P plastic ·2026-10-16#3

Usually not more than a few seconds, but check the token the app is using. Pods that started before you created the binding might have an old projected token, though those refresh. More likely the app is using a different service account than you think: kubectl get pod in prod with a jsonpath for spec.serviceAccountName will tell you.

⚑ Report
☆ 0
C cache ·2026-10-21#4

Also check for a ClusterRoleBinding elsewhere, though Kubernetes RBAC is additive so there's no explicit deny. If the pod's serviceAccountName is default then that's your answer. We add a check in our deploy script that asserts kubectl auth can-i returns yes before rolling out, catches this every time.

⚑ Report
Log in to reply.