RBAC API Objects Overview
What you'll learn: The four core API objects that make Kubernetes RBAC work and how they fit together.
The Four Core Objects
Kubernetes RBAC relies on four main API objects that work in pairs: Roles and ClusterRoles define what can be done, while RoleBindings and ClusterRoleBindings define who can do it.
Roles and ClusterRoles: Defining Permissions
Think of these as "permission templates" that list what actions (verbs) can be performed on which resources.
- Role: Grants permissions within a single namespace. Example: "read pods in the dev namespace."
- ClusterRole: Grants permissions cluster-wide or on non-namespaced resources. Example: "read nodes" or "manage secrets in any namespace."
RoleBindings and ClusterRoleBindings: Granting Permissions
These objects connect subjects (users, groups, or ServiceAccounts) to Roles or ClusterRoles—essentially saying "User X can do what Role Y allows."
- RoleBinding: Binds a Role (or ClusterRole) to subjects within a specific namespace. Even if you reference a ClusterRole, the permissions only apply in that namespace.
- ClusterRoleBinding: Binds a ClusterRole to subjects cluster-wide. This grants permissions across all namespaces or on cluster-scoped resources.
The Pattern
The pattern is simple: Define permissions (Role/ClusterRole) → Assign them (RoleBinding/ClusterRoleBinding).
Use Roles and RoleBindings when working within a single namespace. Use ClusterRoles and ClusterRoleBindings for cluster-wide access or when managing non-namespaced resources like nodes or persistent volumes.
Key Takeaway: RBAC uses four objects—Role and ClusterRole define permissions, while RoleBinding and ClusterRoleBinding grant those permissions to users, groups, or ServiceAccounts.