Reputation: 61
We all know that kubectl auth can-i <verb> <resource> --as=system:serviceaccount:<namespace>:<serviceaccountname> [-n <namespace>]
can be used to check if a serviceaccount has a specific permission, but is there a way that I can check what rol/clusterrole a serriceaccount is bound to?
Upvotes: 0
Views: 238
Reputation: 811
kubectl get rolebindings,clusterrolebindings \
--all-namespaces \
-o custom-columns='KIND:kind,NAMESPACE:metadata.namespace,NAME:metadata.name,SERVICE_ACCOUNTS:subjects[?(@.kind=="ServiceAccount")].name' | grep "<SERVICE_ACCOUNT_NAME>"
Upvotes: 2