- 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.
1) Identify the API server authorization modes
Check the static manifest used by kube-apiserver:Node,RBAC authorization modes.
2) Count Roles (default namespace and cluster-wide)
Check Roles in the default namespace:- Default namespace: no Roles shown.
- All namespaces combined: 12 Roles.
3) Inspect Role permissions: kube-proxy Role in kube-system
Describe thekube-proxy Role:
- The
kube-proxyRole grants access toconfigmaps. - It is restricted to the specific
resourceNamekube-proxyand only allows thegetverb.
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 inkube-system:
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:
dev-user can list pods in default:
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:
dev-user to the Role:
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:
blue:
- The
developerRole inblueusesresourceNames: [blue-app], so the Role only applies to the pod namedblue-app. dark-blue-appis not covered, sodev-useris denied.
- Edit the
developerRole to includedark-blue-appinresourceNames. - Or remove
resourceNamesso the role applies to all pods in the namespace (use with caution — see warning).
resourceNames with dark-blue-app):
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:
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:
developer Role that grants both pod access (for dark-blue-app) and Deployments:
kubectl edit role developer -n blue) and verify:
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-proxyRole only allowsgeton thekube-proxyConfigMap and is bound to thesystem:bootstrappers:kubeadm:default-node-tokengroup. - Created a
developerRole and RoleBinding indefaultto allowdev-userto manage pods there. - Troubleshot a forbidden error in the
bluenamespace caused byresourceNamesrestricting access toblue-apprather thandark-blue-app. - Extended the Role to include
deploymentsin theappsAPI group to allowdev-userto create Deployments.