How can I debug all Rules
with their Verbs
and ApiGroups
for a kubernetes ServiceAccount
?
kubectl
supports testing the RBAC rights for a particular Service Account with the auth can-i
sub-command. The syntax looks as follows:
kubectl auth can-i -n --as system:serviceaccount:<namespace>:<serviceaccount> <verb> <resource>
For example:
kubectl auth can-i --as system:serviceaccount:default:my-serviceaccount create deployments
More information can be found here.
k9s offer some nice views for this task:
1. Find Role Bindings
First you have to find the ClusterRoleBindings or RoleBindings for a ServiceAccount:
:
and clusterrolebindings
or rolebindings
/
and name of ServiceAccount (e.g. monitor-kube-prometheus-st-operator
)(Cluster)RoleBindings
2. Display Role Bindings