Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes: Diffrerence between RoleBinding and ClusterRoleBinding

Tags:

kubernetes

What is the difference between RoleBinding and ClusterRoleBinding? And what are the usages of them?

like image 799
Janitha Madushan Avatar asked Apr 21 '26 10:04

Janitha Madushan


2 Answers

A rolebinding is namespace scoped and clusterrolebinding is cluster scoped i.e across all namespace.

ClusterRoles and ClusterRoleBindings are useful in the following cases:

  1. Give permissions for non-namespaced resources like nodes

  2. Give permissions for resources in all the namespaces of a cluster

  3. Give permissions for non-resource endpoints like /healthz

A RoleBinding can also reference a ClusterRole to grant the permissions defined in that ClusterRole to resources inside the RoleBinding's namespace. This kind of reference lets you define a set of common roles across your cluster, then reuse them within multiple namespaces.

like image 186
Arghya Sadhu Avatar answered Apr 24 '26 12:04

Arghya Sadhu


Please refer the Kubernetes documentation here

A Role always sets permissions within a particular namespace; when you create a Role, you have to specify the namespace it belongs in.

ClusterRole, by contrast, is a non-namespaced resource. The resources have different names (Role and ClusterRole) because a Kubernetes object always has to be either namespaced or not namespaced; it can’t be both.

like image 44
Bimal Avatar answered Apr 24 '26 11:04

Bimal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!