Skip to main content
This lab walks through inspecting and managing Role-Based Access Control (RBAC) on a Kubernetes cluster. You will:
  • Confirm the API server’s authorization modes.
  • Inspect existing Roles and RoleBindings.
  • Create Roles and RoleBindings for a user (dev-user).
  • Troubleshoot permission failures and extend Roles to cover additional API groups.
Relevant links and references:

1) Identify the API server authorization modes

Check the static manifest used by kube-apiserver:
Relevant excerpt showing the flag:
You can also confirm from the running process:
Example output fragment:
Conclusion: the API server uses Node,RBAC authorization modes.

2) Count Roles (default namespace and cluster-wide)

Check Roles in the default namespace:
Check all namespaces and count:
Summary:
  • Default namespace: no Roles shown.
  • All namespaces combined: 12 Roles.
Quick reference (commands and purpose):

3) Inspect Role permissions: kube-proxy Role in kube-system

Describe the kube-proxy Role:
Example output:
Key points:
  • The kube-proxy Role grants access to configmaps.
  • It is restricted to the specific resourceName kube-proxy and only allows the get verb.
Roles can be scoped to specific resource names using resourceNames. Here, the Role allows only get on the ConfigMap named kube-proxy, not on all ConfigMaps.

4) Find which subjects (accounts/groups) are bound to the kube-proxy Role

List RoleBindings in kube-system:
Inspect the specific binding:
Relevant subjects excerpt:
Conclusion: kube-proxy Role is bound to the group system:bootstrappers:kubeadm:default-node-token.

5) Confirm dev-user exists in the kubeconfig and test current permissions

View users in kubeconfig:
Excerpt showing users:
Test whether dev-user can list pods in default:
Expected error:
Result: dev-user lacks permission to list pods in default.

6) Create Role and RoleBinding to allow pod operations for dev-user in default

Create a Role named developer in default allowing list, create, and delete on pods:
Verify the Role:
Output:
Bind dev-user to the Role:
Verify the RoleBinding:
Output:
Result: dev-user can now list, create, and delete pods in the default namespace.

7) Troubleshoot: dev-user cannot get dark-blue-app in the blue namespace

Run the failing command as dev-user:
Error:
Inspect Roles and RoleBindings in blue:
Output:
Diagnosis:
  • The developer Role in blue uses resourceNames: [blue-app], so the Role only applies to the pod named blue-app.
  • dark-blue-app is not covered, so dev-user is denied.
Fix options:
  • Edit the developer Role to include dark-blue-app in resourceNames.
  • Or remove resourceNames so the role applies to all pods in the namespace (use with caution — see warning).
Example Role patch (replace resourceNames with dark-blue-app):
Apply the change (for example, kubectl edit role developer -n blue) and retry:
Removing resourceNames makes the Role apply to all pods in the namespace. Only do this if you intend to grant broader access; otherwise prefer listing explicit resourceNames to maintain least privilege.

8) Grant dev-user permission to create Deployments (apps API group) in blue

When dev-user tried to create a Deployment:
Error:
Add a rule to the developer Role in blue that allows deployments in the apps API group. Ensure the plural resource name deployments is used. Example Role fragment to add:
A full example developer Role that grants both pod access (for dark-blue-app) and Deployments:
Apply the edit (e.g., kubectl edit role developer -n blue) and verify:
Expected policy rules:
Now dev-user can create a Deployment:

Summary

  • Verified the API server is configured with Node,RBAC.
  • Counted Roles cluster-wide (12) and confirmed none in default.
  • Found kube-proxy Role only allows get on the kube-proxy ConfigMap and is bound to the system:bootstrappers:kubeadm:default-node-token group.
  • Created a developer Role and RoleBinding in default to allow dev-user to manage pods there.
  • Troubleshot a forbidden error in the blue namespace caused by resourceNames restricting access to blue-app rather than dark-blue-app.
  • Extended the Role to include deployments in the apps API group to allow dev-user to create Deployments.
Further reading:

Watch Video