Skip to main content
This lesson shows how to inspect cluster-scoped RBAC objects (ClusterRoles and ClusterRoleBindings) and how to create ClusterRoles and ClusterRoleBindings to grant a user (michelle) access to node and storage resources. You’ll learn how to determine API groups for resources, create fine-grained cluster roles, bind them to a user, and verify access.

Inspect existing ClusterRoles

Count all ClusterRoles in the cluster:
View a short excerpt of the ClusterRoles present:
Note that ClusterRoles are cluster-scoped (not namespaced) and can grant permissions across the entire cluster.
ClusterRoles and ClusterRoleBindings are cluster-scoped resources. Use kubectl get clusterroles and kubectl get clusterrolebindings to list them and kubectl describe to inspect specific objects.
A quick reference table for common ClusterRoles:

Inspect ClusterRoleBindings

Count ClusterRoleBindings:
Find ClusterRoleBindings that reference the cluster-admin role:
Describe the cluster-admin ClusterRoleBinding to see its subjects:
This shows the cluster-admin ClusterRole is bound to the system:masters group, granting full privileges to that group.
Be careful when binding cluster-admin. It grants unrestricted cluster access. Prefer creating minimal ClusterRoles for users that only need specific cluster-scoped permissions.

What permissions does the cluster-admin ClusterRole grant?

Describe the cluster-admin ClusterRole to inspect its policy rules:
This indicates cluster-admin grants all verbs (*) for all resources and non-resource URLs across the cluster.

Grant node access to user “michelle”

Michelle needs read access to nodes (to inspect and monitor them). First, confirm Michelle does not currently have node-listing permission:
Create a minimal ClusterRole that allows get, list, and watch on nodes, and bind it to Michelle. Create the ClusterRole:
Create the ClusterRoleBinding to attach the role to the user michelle:
Verify the ClusterRole:
Verify the ClusterRoleBinding:
Test the access as Michelle:
Michelle can now list and inspect nodes.
Michelle needs access to storage resources: PersistentVolumes and StorageClasses. First, confirm the resource names and API groups using kubectl api-resources:
Create a ClusterRole that permits list, create, get, and watch on persistentvolumes and storageclasses:
Inspect the created ClusterRole in YAML to confirm apiGroups and rules:
Bind the storage-admin ClusterRole to Michelle:
Test as Michelle to list StorageClasses:
Michelle can now access the specified storage resources (PersistentVolume and StorageClass) per the permissions granted.

Summary

  • ClusterRoles and ClusterRoleBindings are cluster-scoped and control access across the entire cluster.
  • Use minimal, purpose-specific ClusterRoles instead of broad roles like cluster-admin when possible.
  • You can grant a non-privileged user access to specific cluster-scoped resources by creating a ClusterRole and binding it with a ClusterRoleBinding.
  • Always verify permissions by attempting actions using --as <user>.

Watch Video