Kubernetes RBAC Explained: Roles, ClusterRoles, Bindings and Service Accounts
Secure Kubernetes access with RBAC: Roles vs ClusterRoles, RoleBindings, service accounts for pods, least privilege examples and auditing permissions.
Published December 2, 2026
Role-Based Access Control (RBAC) decides who can do what in a Kubernetes cluster: which users can deploy to production, which CI pipelines can update which namespaces, and which pods can read Secrets or list other pods. Misconfigured RBAC is one of the most common causes of Kubernetes security incidents, and it is straightforward to get right with a few patterns.
The concept
RBAC has four object types. A Role grants permissions (verbs like get, list, create, update, delete on resources like pods or deployments) within one namespace. A ClusterRole grants permissions cluster-wide or on cluster-scoped resources, and can also be reused inside namespaces. A RoleBinding grants a Role or ClusterRole to subjects in one namespace; a ClusterRoleBinding grants a ClusterRole across the whole cluster.
Subjects are users, groups (usually from your identity provider via OIDC or the cloud provider) and service accounts. Every pod runs as a service account, and its token lets the pod call the Kubernetes API. Most applications never need to call the API at all, so they should use a dedicated service account with no permissions and, ideally, automountServiceAccountToken disabled.
How RBAC fits together
The four objects
| Object | Scope | Example |
|---|---|---|
| Role | One namespace | Read pods and logs in "shop" |
| ClusterRole | Cluster-wide or reusable | Read nodes; built-in view/edit/admin |
| RoleBinding | One namespace | Team "payments" gets edit in "payments" |
| ClusterRoleBinding | Whole cluster | Platform admins get cluster-admin (sparingly) |
Least-privilege pattern
- Map people to groups in your identity provider
- Give teams namespace-scoped edit/view via RoleBindings
- Give CI a service account limited to its namespaces
- Give apps service accounts with no permissions by default
- Audit regularly with kubectl auth can-i and RBAC tools
Practical examples
Read-only access to pods and logs in one namespace
Role plus RoleBinding to a group.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: { name: pod-reader, namespace: shop }
rules:
- apiGroups: [""]
resources: [pods, pods/log]
verbs: [get, list, watch]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata: { name: support-pod-reader, namespace: shop }
subjects: [{ kind: Group, name: support-team, apiGroup: rbac.authorization.k8s.io }]
roleRef: { kind: Role, name: pod-reader, apiGroup: rbac.authorization.k8s.io }Check permissions
Ask the API server what a subject can do.
kubectl auth can-i delete deployments -n shop --as=jane@example.com
kubectl auth can-i --list -n shop --as=system:serviceaccount:shop:apiAn app service account with no API access
Disable token mounting when the app does not call Kubernetes.
apiVersion: v1
kind: ServiceAccount
metadata: { name: api, namespace: shop }
automountServiceAccountToken: falseCommon mistakes
- Binding cluster-admin to CI pipelines or developers by default.
- Granting list on Secrets cluster-wide (lists return secret values).
- Pods running with the default service account that has extra permissions.
- Wildcard verbs and resources ("*") in custom roles.
Key takeaways
- Roles/ClusterRoles define permissions; bindings grant them.
- Prefer namespace-scoped RoleBindings for teams.
- Give pods dedicated service accounts with minimal or no permissions.
- Audit with kubectl auth can-i and avoid wildcards.
FAQ
Does Kubernetes manage user accounts?
No. Users come from external identity (certificates, OIDC, cloud IAM). RBAC only authorises them.
What are the built-in roles?
ClusterRoles view, edit, admin and cluster-admin cover common cases and can be bound per namespace.
Is RBAC enough for pod security?
No. Combine it with Pod Security Admission, NetworkPolicies and image policies.