Grant least privilege with Roles and bindings
- 14 min
- 5 steps
- Security
Steps
0 of 5 done
Read a forbidden error, grant a workload exactly one resource, give a support identity in another namespace read access, and move a binding to a different role.
Step 1 of 5
The
reporterDeployment inshopis crash-looping. Find the request the API server refused it, and the username it saw.Checked against what your commands print.
Step 2, not started: Let
reporterread ConfigMaps inshop, and nothing else. It needs to get, list and watch them.Step 3, not started: The
supportServiceAccount lives inops. Inshopit must be able to list pods and read their logs, and must not be able to exec into them. Name the Rolelog-readerand the RoleBindingsupport-logs.Step 4, not started: Support needs read-only access to everything ordinary in
shop, without Secrets and without anything in other namespaces. The built-inviewClusterRole covers that, pod logs included. Makesupport-logsgrantviewinstead oflog-reader, then remove the Role nobody uses.Step 5, not started: List the bindings in
shopwith the role and the subjects of each, the view you would start from when asked who has access to the namespace.
Enter runs the command. Tab completes, and the arrow keys recall earlier commands. Control C stops a watch. On an empty line, or after Escape, Tab moves focus out of the terminal.