Inspect existing ClusterRoles
Count all ClusterRoles in the cluster:cluster-admin, controller roles, and add-on roles such as system:coredns or local-path-provisioner-role.
Inspect existing ClusterRoleBindings
Count ClusterRoleBindings:ClusterRoles and ClusterRoleBindings are cluster-scoped objects — they do not belong to any namespace.
Check who has cluster-admin
Find ClusterRoleBindings that reference thecluster-admin ClusterRole:
cluster-admin ClusterRoleBinding to view its subjects:
system:masters group is bound):
cluster-admin ClusterRole to see the full privileges it grants:
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 asmichelle:
michelle:
Task: Grant Michelle access to storage (PersistentVolumes and StorageClasses)
Michelle now needs permissions for storage resources. Usekubectl api-resources to determine resource names, short names, API groups, and whether a resource is namespaced:
Create a ClusterRole that allows Michelle to
list, create, get, and watch PersistentVolumes and StorageClasses:
storage-admin ClusterRole to Michelle:
Quick reference: Useful kubectl commands
Summary
- ClusterRoles and ClusterRoleBindings are cluster-scoped RBAC objects.
cluster-admingrants full cluster privileges and is typically bound tosystem: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-resourcesto discover resource names, shortnames, API groups, and whether a resource is namespaced.
Links and references
- Kubernetes RBAC: https://kubernetes.io/docs/reference/access-authn-authz/rbac/
- kubectl reference: https://kubernetes.io/docs/reference/kubectl/overview/
- kubectl api-resources: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#api-resources