Skip to main content
This lesson walks through ClusterRoles and ClusterRoleBindings: how to inspect what’s already in the cluster, examine who has cluster-admin privileges, and create ClusterRoles and ClusterRoleBindings to grant a user (michelle) access to cluster-scoped resources (nodes and storage).

Inspect existing ClusterRoles

Count all ClusterRoles in the cluster:
Example output (your environment will vary; this environment shows 69):
ClusterRoles are cluster-scoped (not namespaced). To list them:
You will see many system roles, for example cluster-admin, controller roles, and add-on roles such as system:coredns or local-path-provisioner-role.

Inspect existing ClusterRoleBindings

Count ClusterRoleBindings:
Example output in this environment:
ClusterRoleBindings are cluster-scoped as well.
ClusterRoles and ClusterRoleBindings are cluster-scoped objects — they do not belong to any namespace.

Check who has cluster-admin

Find ClusterRoleBindings that reference the cluster-admin ClusterRole:
Example output:
Describe the cluster-admin ClusterRoleBinding to view its subjects:
Example output (shows the system:masters group is bound):
Inspect the cluster-admin ClusterRole to see the full privileges it grants:
Example output:
This shows cluster-admin grants full access across all resources and non-resource URLs.
The cluster-admin role provides full cluster-wide privileges. Bind it only to trusted users or service accounts.

Task: Grant Michelle access to nodes

Michelle currently cannot list nodes. To see the error when attempting to list nodes as michelle:
Example error:
To grant Michelle read-only access to nodes (list/get/watch), create a ClusterRole and bind it to her: Create the ClusterRole:
Create the ClusterRoleBinding that ties the role to the user michelle:
Verify the ClusterRole:
Example output:
Verify the ClusterRoleBinding:
Example output:
Test the permission as Michelle:
Example successful output:

Task: Grant Michelle access to storage (PersistentVolumes and StorageClasses)

Michelle now needs permissions for storage resources. Use kubectl api-resources to determine resource names, short names, API groups, and whether a resource is namespaced:
Relevant cluster-scoped storage resources include: Create a ClusterRole that allows Michelle to list, create, get, and watch PersistentVolumes and StorageClasses:
Describe the new ClusterRole:
Example output:
You can also view the ClusterRole YAML:
Example YAML output:
Bind the storage-admin ClusterRole to Michelle:
Verify Michelle can list storage classes (or persistent volumes) by running as Michelle:
If the binding is configured correctly, Michelle will be able to list StorageClasses and PersistentVolumes.

Quick reference: Useful kubectl commands

Summary

  • ClusterRoles and ClusterRoleBindings are cluster-scoped RBAC objects.
  • cluster-admin grants full cluster privileges and is typically bound to system:masters.
  • To grant a user access to cluster-scoped resources (nodes, PVs, StorageClasses), create a ClusterRole with the necessary verbs and resources, then create a ClusterRoleBinding to associate the role with the user (or group or service account).
  • Use kubectl api-resources to discover resource names, shortnames, API groups, and whether a resource is namespaced.

Watch Video