Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 104/ 160
06. Security, RBAC & Governance

Role-Based Access Control (RBAC): Role, ClusterRole, RoleBinding, ClusterRoleBinding

Authorize who can do what with Roles, ClusterRoles, and bindings.

BeginnerRole · ClusterRole · Bindings3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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 alice and 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

Loading interactive 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.

Verify ClusterRole, not only object creation

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.

Key takeaway: Role is implemented only when this invariant remains observable: 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.

Recover from ClusterRole drift

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.

Key takeaway: Accept the trade-off consciously: Least privilege limits credential blast radius, but many granular bindings create drift and require systematic grouping and impersonation tests.

How it works, step by step

Step 1 of 4
Identity owner

1. 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.

Role contract → owned state
Key numbers at this step
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 alice in 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 alice first: 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

Admission and least privilege
Best for: Authorize who can do what with Roles, ClusterRoles, and bindings. A concrete incident check is 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.

Runtime-only detection
Best for: Quickly testing the ClusterRole assumption with 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.

Hosted security service
Best for: Teams that need Bindings integrated with guardrails; the evidence path is 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 alice without 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?
Interview tip: Interview sequence: state the invariant, run 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

Loading quiz

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.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
ServiceAccounts & Projected Bound Tokens
Next topic
Auditing & Debugging RBAC Permissions (kubectl auth can-i)