Kubernetes: Diffrerence between RoleBinding and ClusterRoleBinding

4/3/2020

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

-- JMadushan
kubernetes

3 Answers

4/3/2020

The Cluster variants apply to every namespace. The others only to the namespace they are in.

-- coderanger
Source: StackOverflow

4/3/2020

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.

-- Bimal
Source: StackOverflow

4/3/2020

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.

-- Arghya Sadhu
Source: StackOverflow