Created
September 30, 2021 02:28
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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