Challenge ·Medium

Troubleshoot RBAC Permissions for a Failing Deployment

A Deployment is failing because its ServiceAccount lacks permissions to list pods. Fix the issue by binding an existing Role to the ServiceAccount.

Scenario

A Deployment named pod-explorer in the qa-tools namespace is failing with the following error:

Caution

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

  1. Analyse all Roles in the qa-tools namespace, examine each one, and identify which Role grants permission to list Pods within the same namespace.
  2. Create a RoleBinding named explorer-rolebinding that binds the correct Role to the ServiceAccount sa-explorer
  3. Verify that the Deployment logs show successful pod listing without permission errors

Hint
  • Use kubectl get roles -n qa-tools to list available Roles
  • Use kubectl describe role <role-name> -n qa-tools to inspect each Role's permissions
  • Look at the Resources and Verbs fields to understand what each Role allows
  • Use kubectl create rolebinding -h to see available flags for binding a Role to a ServiceAccount

See the official docs: Using RBAC Authorization


Test Cases