DevOps Dictionary

Kubernetes ClusterRoleBinding

Kubernetes ClusterRoleBinding is a Role-Based Access Control, or RBAC, object that grants a ClusterRole to one or more users, groups, or service accounts across the whole Kubernetes cluster. It connects “what actions are allowed” to “who can perform them” at cluster scope.

What a ClusterRoleBinding does

A ClusterRoleBinding gives subjects the permissions defined in a ClusterRole. Because it is cluster-scoped, the access applies across all namespaces when the ClusterRole contains rules for namespaced resources such as Pods, Deployments, or ConfigMaps.

It is commonly used for permissions that need to work beyond a single namespace, such as:

  • Granting read-only access to all namespaces for an audit or observability team.
  • Giving a controller or operator permission to watch resources across the cluster.
  • Assigning cluster administration access to a trusted platform team group.
  • Allowing monitoring agents to list Pods, Nodes, Services, and Endpoints cluster-wide.

How it works

Kubernetes RBAC separates permissions into two parts:

  • ClusterRole: Defines allowed actions, such as get, list, watch, create, update, or delete.
  • ClusterRoleBinding: Assigns that ClusterRole to one or more subjects.

When a request reaches the Kubernetes API server, the RBAC authorizer checks the authenticated identity against RoleBindings and ClusterRoleBindings. If a matching binding grants the requested verb on the requested resource, Kubernetes allows the request.

Key fields in a ClusterRoleBinding

  • metadata.name: The name of the ClusterRoleBinding.
  • subjects: The identities receiving access. A subject can be a User, Group, or ServiceAccount.
  • roleRef: The ClusterRole being granted. This points to a ClusterRole in the rbac.authorization.k8s.io API group.

The roleRef field is effectively fixed after creation. If you need to point the binding to a different role, delete and recreate the ClusterRoleBinding.

Simple example

This example grants the built-in view ClusterRole to a service account named metrics-reader in the monitoring namespace:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: metrics-reader-view
subjects:
  - kind: ServiceAccount
    name: metrics-reader
    namespace: monitoring
roleRef:
  kind: ClusterRole
  name: view
  apiGroup: rbac.authorization.k8s.io

With this binding, the service account can read many common Kubernetes resources across namespaces, according to the rules in the view ClusterRole. It does not automatically receive permission to read Secrets unless the ClusterRole allows that.

You can test access with:

kubectl auth can-i list pods --all-namespaces \
  --as=system:serviceaccount:monitoring:metrics-reader

ClusterRoleBinding vs RoleBinding

A RoleBinding grants access inside one namespace. It can bind either a Role or a ClusterRole, but the access remains limited to that namespace.

A ClusterRoleBinding grants access at cluster scope. If the ClusterRole includes permissions for namespaced resources, those permissions apply in every namespace.

Use a RoleBinding when a team, service account, or application only needs access in one namespace. Use a ClusterRoleBinding when the subject truly needs cluster-wide access.

Common use cases

  • Platform administration: Binding a controlled identity provider group to a high-privilege ClusterRole for cluster operations.
  • Observability: Allowing Prometheus, log collectors, or inventory tools to watch resources across namespaces.
  • Operators and controllers: Granting controllers permission to reconcile resources across the cluster. Tools such as Crossplane often need carefully scoped RBAC when you deploy AWS resources using Crossplane on Kubernetes.
  • CI/CD automation: Giving deployment systems access to multiple namespaces, while avoiding broad permissions such as cluster-admin unless there is a clear operational need.
  • Infrastructure as code: Managing bindings through Git, Helm, Kustomize, or Terraform. For example, teams that deploy Kubernetes resources using Terraform often define RBAC objects alongside workloads.

Security considerations

ClusterRoleBindings are powerful because a small YAML change can grant access across the entire cluster. Treat them as security-sensitive configuration.

  • Prefer least privilege: Grant only the verbs and resources the subject needs.
  • Avoid casual use of cluster-admin: This role gives broad control over the cluster and can bypass many intended boundaries.
  • Bind groups instead of individual users where possible: This makes access easier to review and remove through your identity provider.
  • Use dedicated service accounts: Do not reuse one high-privilege service account across unrelated workloads.
  • Review bindings during upgrades: API changes, controller changes, and new workloads can affect what permissions are needed. RBAC review should be part of Kubernetes upgrade planning.
  • Audit regularly: Check who can create Pods, read Secrets, manage RBAC, or impersonate other identities.

Practical rule of thumb

If the subject needs access in one namespace, use a RoleBinding. If the subject needs the same access across every namespace, or needs access to cluster-scoped resources such as Nodes, PersistentVolumes, or CustomResourceDefinitions, use a ClusterRoleBinding.

A ClusterRoleBinding does not define permissions by itself. It only grants the permissions already defined in a ClusterRole. A ClusterRole without a binding grants no access, and a binding that points to an overly broad ClusterRole can grant far more access than intended.

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Y
X
Z