Role-Based Access Control (RBAC): Role, ClusterRole, RoleBinding, ClusterRoleBinding
Authorize who can do what with Roles, ClusterRoles, and bindings.
In plain words
RBAC is a building keycard register: a Role lists doors, and a binding assigns that door list to one identity. The simple Kubernetes rule is: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
Think of it like…
RBAC is a building keycard register: a Role lists doors, and a binding assigns that door list to one identity.
Where you’ve seen it
During an access review, the security engineer runs kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice. Expected evidence: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding. If the run instead shows this symptom, stop and restore the last known state: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere.
Words you’ll hear
- Role
- For this lesson, Role is the controlling idea: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
- ClusterRole
- ClusterRole is the checkpoint; run
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as aliceand inspect the owner chain. Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere. - Bindings
- Bindings is the outcome to preserve; the cost is explicit: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.
- Verification evidence
- The evidence command is
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice. It connects the declaration to this behavior: Authorize who can do what with Roles, ClusterRoles, and bindings.
Visual diagram
Theory & deep dive
How Role reaches the intended state
Authorize who can do what with Roles, ClusterRoles, and bindings. RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
The concrete checkpoint is kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice; compare the Role owner, ClusterRole state, and Bindings outcome instead of treating YAML acceptance as proof.
Run kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice after the change and correlate the result with Events and the owning object. RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
ClusterRole: failure boundary and production cost
Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere. The prerequisite contract is concrete: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests. A safe design limits blast radius, records the last good configuration, and uses kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice as a deterministic rollback checkpoint.
Capture the current state with kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere.
How it works, step by step
Step 1 of 41. Model the trust boundary
Name the identity, action, resource, and trust boundary before choosing a control: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
- Goal
- Authorize who can do what with Roles, ClusterRoles, and bindings.
- Owner
- Role
When to use it & trade-offs
What it is
Authorize who can do what with Roles, ClusterRoles, and bindings. RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
Why it matters: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere. The invariant at risk is specific: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding. The quickest fact check before changing the design is kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice.
When to reach for it
- Use Role to enforce this invariant: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
- Use ClusterRole evidence from
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alicein reviews and incident timelines. Authorize who can do what with Roles, ClusterRoles, and bindings. - Choose the hosted security service route only when this cost is justified by governance or scale: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.
When to avoid or be careful
- Avoid assuming Role is complete after YAML submission; the required behavior is concrete: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
- Avoid treating the next symptom as random; check the owner and state with
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alicefirst: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere. - Avoid adopting a heavier platform wrapper before measuring its cost: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.
Native, manual, and managed paths for Role
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice.Strengths: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
Watch out: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests. Recovery must also recognize this signal: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere.
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice; the expected invariant is: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.Strengths: kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice gives immediate feedback without first building a platform layer.
Watch out: A manual change can hide drift, and unlike Role, it does not make this symptom self-documenting: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere.
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice.Strengths: Platform controls can wrap this exact behavior in policy or dashboards: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
Watch out: The added platform ownership buys value at this cost: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.
Interview signals & numbers to know
When this topic comes up
- Interview anchor: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
- Trace Role to Bindings through ClusterRole; the invariant is: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
- Recognize the symptom: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere.
- Justify the cost: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.
- Verify with kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice instead of only inspecting YAML.
Benchmarks & rules of thumb
- 4
- objects to distinguish: Role, ClusterRole, RoleBinding, and ClusterRoleBinding
- 2
- authorization scopes: namespace and cluster
- 0
- explicit deny semantics in standard RBAC
Common mistakes & follow-ups
Common interview mistakes
- Debugging only the child object misses the Role owner contract: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding.
- Ignoring this telltale condition leads to unrelated changes: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere.
- Repeating
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alicewithout an owner for remediation wastes retry cost. Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.
Likely interviewer follow-ups
- How would API output and runtime evidence prove this behavior: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding?
- Which owner object, logs, and Events would you inspect for this symptom-Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere-?
- At what threshold would this cost become unacceptable: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests?
kubectl get role,rolebinding,clusterrole,clusterrolebinding -A; kubectl auth can-i create deployments.apps -n payments --as alice, name the failure, then justify the cost. Invariant: RBAC grants additive permissions from Role or ClusterRole rules through RoleBinding or ClusterRoleBinding; the names and subjects do not receive permissions without a binding. Failure: Permissions added to a ClusterRoleBinding are cluster-wide, wildcard verbs or resources silently broaden scope, and no RBAC deny rule overrides an accidental allow elsewhere. Cost: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Role-Based Access Control (RBAC): Role, ClusterRole, RoleBinding, ClusterRoleBinding with generative AI interview Q&A and hands-on practice.