Skip to content

Instantly share code, notes, and snippets.

@georgegoh
Created September 30, 2021 02:28
Show Gist options
  • Save georgegoh/24d0dc5c56e596a573d6af96596dc5e2 to your computer and use it in GitHub Desktop.
Save georgegoh/24d0dc5c56e596a573d6af96596dc5e2 to your computer and use it in GitHub Desktop.
Get roles with rules using PSP with the name defined in the env var $PSP
kubectl get role -A -o json | jq '.items[] | . as $role | .rules[] | .resources | if any(. == "podsecuritypolicies") then $role else empty end' \
| jq --arg psp $PSP 'try . as $role | .rules[] | .resourceNames | if any(. == $PSP) then $role else empty end'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment