Learning center

Diagnose a Kubernetes RoleBinding in the wrong namespace

A RoleBinding grants access in the namespace that holds the binding, even when it references a ClusterRole. Inspect the namespace of the requested object and the namespace of the bound subject separately.

In a fictional cluster, service account jobs/report-reader needs to get ConfigMap report-format in reports. An existing binding in jobs refers to a ClusterRole with the right verb and resource. An operator with RBAC read access can list the bindings in the target namespace and inspect the known binding in the other namespace.

kubectl get rolebindings -n reports
kubectl get rolebinding report-reader -n jobs -o yaml

Compare the binding namespace with the request namespace. If the access is approved and no binding covers the reports request, ask that namespace's owner to evaluate a local binding with the intended subject and rule. A ClusterRoleBinding would grant the role at cluster scope. The existing ClusterRole may already be reusable with a namespace-local binding. Kubernetes RBAC RoleBinding and ClusterRoleBinding

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