> For the complete documentation index, see [llms.txt](https://blog.techwithpatil.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.techwithpatil.com/blogs/kubernetes-series-2025/understanding-kubernetes-part-28-clusterrole-and-clusterrolebinding.md).

# Understanding Kubernetes: Part 28 ClusterRole and ClusterRoleBinding

***

<figure><img src="https://cdn-images-1.medium.com/max/800/1*6hyDAfo_F6MxI0LEMmfx6w.png" alt=""><figcaption></figcaption></figure>

📢 If you’ve been following our Kubernetes series 2025, welcome back! For new readers, check out [**Part 27: Role and RoleBinding**](https://techwithpatil.medium.com/understanding-kubernetes-part-27-role-and-rolebinding-95363bd30dc1)

#### What is a ClusterRole?

A **ClusterRole** is similar to a Role but applies permissions cluster-wide instead of being restricted to a specific namespace.

#### What is a ClusterRoleBinding?

A **ClusterRoleBinding** associates a ClusterRole with a user, group, or service account, granting them the specified permissions at the cluster level.

***

#### Use Cases

ClusterRole and ClusterRoleBinding are useful in various scenarios:

#### 1. Granting Read-Only Access to All Namespaces

* Providing read-only permissions to developers for all cluster resources.

#### 2. Managing Cluster-Wide Resources

* Controlling access to cluster-wide resources like nodes, persistent volumes, and namespaces.

#### 3. Granting Admin Access Across Namespaces

* Assigning administrative privileges to users who need to manage resources across multiple namespaces.

***

#### ClusterRole Syntax

A **ClusterRole** is created using the following YAML configuration:

```
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: cluster-admin-role
rules:
  - apiGroups: [""]
    resources: ["pods", "services", "nodes"]
    verbs: ["get", "list", "watch"]
```

This ClusterRole allows listing and reading Pods, Services, and Nodes across the cluster.

***

#### ClusterRoleBinding Syntax

A **ClusterRoleBinding** links a ClusterRole to a user, group, or service account.

```
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: cluster-admin-binding
subjects:
  - kind: User
    name: john-doe
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  name: cluster-admin-role
  apiGroup: rbac.authorization.k8s.io
```

This binding grants the user `john-doe` the permissions defined in `cluster-admin-role` across the cluster.

***

#### Removing ClusterRole and ClusterRoleBinding

To delete a ClusterRole:

```
kubectl delete clusterrole cluster-admin-role
```

To delete a ClusterRoleBinding:

```
kubectl delete clusterrolebinding cluster-admin-binding
```

***

#### Conclusion

**ClusterRole and ClusterRoleBinding** are essential for managing cluster-wide access in Kubernetes. They provide fine-grained permissions across all namespaces, ensuring secure access control and resource management.

***

#### In My Previous Role

As a Senior DevOps Engineer, I utilized Kubernetes ClusterRoles and ClusterRoleBindings for efficient access management:

* **Read-Only Access**: Assigned ClusterRoles for developers to inspect cluster-wide resources without modification rights.
* **Cluster-Wide Management**: Used ClusterRoles for managing node-level permissions and security configurations.
* **Admin Access Control**: Configured ClusterRoleBindings to enforce least privilege access while ensuring smooth operations.

#### 🚀 Ready to Master Kubernetes?

Take your Kubernetes journey to the next level with the **Master Kubernetes: Zero to Hero course!** 🌟 Whether you’re a beginner or aiming to sharpen your skills, this hands-on course covers:

✅ Kubernetes Basics — Grasp essential concepts like nodes, pods, and services. \
✅ Advanced Scaling — Learn HPA, VPA, and resource optimization. \
✅ Monitoring Tools — Master Prometheus, Grafana, and AlertManager. \
✅ Real-World Scenarios — Build production-ready Kubernetes setups.

#### 🔥 Flash Sale: Buy Kubernetes Course, Get Terraform FREE! Limited Time Offer!

🔥 Start Learning Now: \[Join the Master Kubernetes Course + FREE Access to Terraform Course]\([**https://cloudops0.gumroad.com/l/k8s**](https://cloudops0.gumroad.com/l/k8s))

Don’t miss your chance to become a Kubernetes expert! 💻✨

🚀 Stay ahead in DevOps and SRE! 🔔 [**Subscribe now**](https://techwithpatil.medium.com/subscribe) and never miss a beat on Kubernetes and more. 🌟

#### 🚀 Master Terraform: Infrastructure as Code

🔥 **Start Learning Now:** [Join the Master Terraform Course](https://medium.com/@techwithpatil/understanding-kubernetes-part-26-preemption-and-priority-316ac93cfba0#)
