Troubleshoot RBAC Permissions for a Failing Deployment
Scenario
A Deployment named pod-explorer in the qa-tools namespace is failing with the following error:
Error from server (Forbidden): pods is forbidden: User "system:serviceaccount:qa-tools:sa-explorer" cannot list resource "pods" in API group "" in the namespace "qa-tools"FAILED
The security team has created several Roles in the namespace with generic names for different purposes.
Task
- Analyse all Roles in the
qa-toolsnamespace, examine each one, and identify which Role grants permission to list Pods within the same namespace. - Create a RoleBinding named
explorer-rolebindingthat binds the correct Role to the ServiceAccountsa-explorer - Verify that the Deployment logs show successful pod listing without permission errors
Hint
- Use
kubectl get roles -n qa-toolsto list available Roles - Use
kubectl describe role <role-name> -n qa-toolsto inspect each Role's permissions - Look at the
ResourcesandVerbsfields to understand what each Role allows - Use
kubectl create rolebinding -hto see available flags for binding a Role to a ServiceAccount
See the official docs: Using RBAC Authorization