Get clusterrolebindings for an account?

11/10/2017

How can I use kubectl to get all the roles that a service account has?

I can check the accounts bound to a particular role by doing

kubectl get clusterrolebindings somerole

Do I need to get all roles and then filter down?

-- Jeremy Lewi
kubernetes

1 Answer

11/10/2017

we can use this one. system:authenticated service account part of two roles

 kubectl get clusterrolebindings  -o=jsonpath='{.items[?(@.subjects[].name=="system:authenticated")].roleRef.name}'
system:basic-user system:discovery
-- sfgroups
Source: StackOverflow