What is Kubernetes RBAC?
Why Interviewers Ask This
This is a classic screening question for Kubernetes (K8s) roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
Kubernetes RBAC (Role-Based Access Control) regulates access to Kubernetes API resources based on roles assigned to users, groups, or service accounts. Core RBAC objects: (1) Role: namespaced — defines allowed actions (verbs) on resources within a namespace: apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: production name: pod-reader rules: - apiGroups: [""] # "" = core API group resources: ["pods", "pods/log"] verbs: ["get", "list", "watch"] - apiGroups: ["apps"] resources: ["deployments"] verbs: ["get", "list"]; (2) ClusterRole: cluster-wide — same as Role but non-namespaced. For: cluster-wide resources (nodes, PV), cross-namespace access; (3) RoleBinding: binds a Role (or ClusterRole) to subjects (users, groups, serviceaccounts) within a namespace: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: read-pods namespace: production subjects: - kind: User name: alice apiGroup: rbac.authorization.k8s.io - kind: ServiceAccount name: my-app namespace: production roleRef: kind: Role name: pod-reader apiGroup: rbac.authorization.k8s.io; (4) ClusterRoleBinding: binds ClusterRole to subjects cluster-wide. Service accounts: identity for pods — auto-mounted at /var/run/secrets/kubernetes.io/serviceaccount/. Use RBAC to grant service accounts specific permissions (Secrets access, ConfigMap read, Pod list). kubectl auth can-i: kubectl auth can-i create pods --namespace production --as alice. Principle of Least Privilege: grant minimum required permissions.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Kubernetes (K8s) codebase.
Previous
What is Kubernetes networking model?
Next
What are Kubernetes volumes and persistent storage?