Skip to content

Instantly share code, notes, and snippets.

@sandipchitale
Last active May 31, 2022 15:49
Show Gist options
  • Save sandipchitale/c795734f342c35b5e43c52e08e634bfb to your computer and use it in GitHub Desktop.
Save sandipchitale/c795734f342c35b5e43c52e08e634bfb to your computer and use it in GitHub Desktop.
Show all users #kubectl
kubectl get ClusterRoleBinding,RoleBinding -o jsonpath="{range .items[*]}{range .subjects[*]}{'\n'}{.kind}{','}{.name}{end}{end}" | wsl column -t -s "," -N Type,Name -R 1
kubectl get ClusterRoleBinding,RoleBinding -o go-template-file=ugsa.tpl | wsl column -t -s ','
REM Sort by user, group, sa type
kubectl get ClusterRoleBinding,RoleBinding -A -o go-template-file=%USERPROFILE%\.kube\ugsa.tpl | wsl { head -n 1; sort -k 1 -k 5 -k 6 -t ','; } | wsl column -t -s ','
Binding Type,Binding Name,Role Type,Role Name,Subject Type,Name
{{ range $item := .items -}}
{{- range $subject := .subjects -}}{{- $item.kind -}},{{- $item.metadata.name -}},{{- $item.roleRef.kind -}},{{- $item.roleRef.name -}},{{- $subject.kind}},{{- $subject.name }}
{{ end }}
{{- end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment