RBAC roles and bindings
Permissions are explicit grants
Role-based access control (RBAC) describes permissions separately from identities. A rule contains API groups, resource names and verbs. Bindings connect rules to users, groups or ServiceAccounts. RBAC grants accumulate; a missing rule is not an explicit deny that cancels another grant. In an RBAC-only exercise, a request without a matching grant is not allowed. Real clusters may configure additional authorizers.
subject + verb + API group + resource + namespace + optional name -> matching grant?A read-only Pod observer
The catalog-reader account needs to observe Pod state in book-lab. The Role grants get, list and watch on core Pods, and the RoleBinding assigns these rights to that account. The empty API group denotes the core API, not every group. Reading a Pod does not automatically authorize its logs or Secrets. A Role has no effect until an appropriate binding references it.
apiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata: name: catalog-pod-reader namespace: book-labrules:- apiGroups: [""] resources: [pods] verbs: [get, list, watch]---apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata: name: catalog-pod-reader namespace: book-labsubjects:- kind: ServiceAccount name: catalog-reader namespace: book-labroleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: catalog-pod-readerScope and reusable roles
A ClusterRole defines reusable rules, including rules for cluster-scoped resources or non-resource paths where appropriate. A RoleBinding referencing it grants only applicable namespaced permissions in the binding namespace. A ClusterRoleBinding instead grants the referenced ClusterRole permissions at cluster-wide scope. A RoleBinding may reference a Role only in its own namespace. ServiceAccount subjects include their own namespace, which may differ from the binding namespace.
apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata: name: fixture-settings-readerrules:- apiGroups: [""] resources: [configmaps] resourceNames: [catalog-settings] verbs: [get, list, watch]---apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata: name: fixture-settings-reader namespace: book-labsubjects:- kind: Group name: fixture-support apiGroup: rbac.authorization.k8s.ioroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: fixture-settings-readerObject names and subresources
The settings rule limits access to catalog-settings. For a list or watch constrained by resourceNames, the request needs a matching metadata.name field selector. A top-level create or deletecollection cannot be restricted this way. Pod log access is a separate resource string, pods/log; get pods does not include it. Names are not label selectors. Avoid wildcard permissions because new API resources may become covered without another review.
get configmaps/catalog-settings -> matching namelist configmaps (no name selector) -> no matching grantlist configmaps (metadata.name=catalog-settings) -> matching grantAggregation and least privilege
Aggregated ClusterRoles collect rules from other ClusterRoles selected by labels. The controller manages their combined rules; omit manually maintained rules from the aggregation manifest to avoid ownership conflicts. Review changes to role labels as permission changes. Permissions that alter roles, bind privileges, manage workloads or access sensitive objects require particular scrutiny. Do not grant broad administrative access as a shortcut. Use the fixture decision matrix to find the smallest sufficient grant.
review subject -> resolve binding -> resolve role -> inspect matching rule -> confirm scopeCheck Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
RBAC roles and bindings — knowledge check
Interpret synthetic identity and permission evidence.
What connects a subject to a Role?
What does a RoleBinding to a ClusterRole grant?
What does apiGroups: [""] mean?
Does get pods alone allow reading Pod logs?
What must a name-restricted list include?