Kubernetes interview question · Most asked

How does RBAC work in Kubernetes, and how do you apply least privilege?

Summary

Roles (namespaced) and ClusterRoles (cluster-wide) list allowed verbs on resources; RoleBindings and ClusterRoleBindings grant them to users, groups or ServiceAccounts. Everything is deny-by-default and permissions are additive.

Longer Answer

Least-privilege practice: give each workload its own ServiceAccount with only the permissions it needs (most apps need none, so disable token automounting); bind people through groups from the identity provider; avoid cluster-admin bindings and wildcard verbs; and audit regularly (kubectl auth can-i --list --as=..., tools such as rbac-lookup or kubectl-who-can).

Dangerous permissions to watch: get/list secrets, create pods (can mount any secret or ServiceAccount in the namespace), escalate/bind/impersonate, and nodes/proxy.

Key Points

  • Roles + bindings; deny by default.
  • One ServiceAccount per workload.
  • No cluster-admin or wildcards.
  • Watch secrets, pod create, escalate/impersonate.

More most-asked Kubernetes questions

← All Kubernetes questions