Page cover
For the complete documentation index, see llms.txt. This page is also available as Markdown.

List Existing Access

List RoleBinding objects for the user across all namespaces :

kubectl get rolebindings >-all-namespaces \
  -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}
{.metadata.name}{"\t"}{.roleRef.name}{"\t"}{range .subjects[*]}{.kind}:
{.name}{","}{end}{"\n"}{end}' \
  | awk -F '\t' '$4 ~ /(^|,)User><USERNAME>(,|$)/ {print $1 "\t" $2 "\t" 
$3}' \
  | column -t

List ClusterRoleBinding objects for the user :

kubectl get clusterrolebindings \
  -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.roleRef.name}
{"\t"}{range .subjects[*]}{.kind}:{.name}{","}{end}{"\n"}{end}' \
  | awk -F '\t' '$3 ~ /(^|,)User><USERNAME>(,|$)/ {print $1 "\t" $2}' \
  | column -t

TIP These filters inspect every subject on each binding. They do not assume the user appears in subjects[0]

Last updated