K8s by Example: RBAC
| RBAC controls who can do what in the cluster. Two pieces: a Role defines what actions are allowed on which resources, and a RoleBinding grants that Role to users or ServiceAccounts. Use ClusterRole and ClusterRoleBinding when you need cluster-wide access. |
| role.yaml | |
| Role defines permissions within a namespace. | |
| rolebinding.yaml | |
| RoleBinding grants a Role to subjects (user, group, or ServiceAccount) within a namespace. The Role and RoleBinding must be in the same namespace. Can have multiple subjects. | |
| clusterrole.yaml | |
| ClusterRole + ClusterRoleBinding for cluster-wide access. Use sparingly and prefer namespace-scoped roles. ClusterRoles can also be bound to specific namespaces via RoleBinding. | |
| role-verbs.yaml | |
| Common verbs: | |
| role-resourcenames.yaml | |
| Resource names restrict access to specific objects. Useful for granting access to one ConfigMap or Secret without access to all. Note: resourceNames doesn’t apply to create/list operations. | |
| clusterrole-aggregation.yaml | |
| Aggregated ClusterRoles combine rules from multiple ClusterRoles. Built-in roles like | |
| rolebinding-builtin.yaml | |
| Built-in ClusterRoles: | |
| terminal | |
| Debug RBAC with | |