Last active
September 7, 2021 07:46
-
-
Save bastjan/d4e81d9112093caaf60338f86ab54e2a to your computer and use it in GitHub Desktop.
Find clusterroles with permissions to create/edit namespaces
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
#!/bin/bash | |
set -euo pipefail | |
kubectl --as=cluster-admin get clusterrole -ojson | jq '[ .items[] | |
| select( | |
.rules[]? | |
| select( | |
(.apiGroups[]? == "" or .apiGroups[]? == "*") | |
and | |
(.resources[]? == "namespaces" or .resources[]? == "*") | |
and | |
(.verbs[]? == "create" or .verbs[]? == "update" or .verbs[]? == "patch" or .verbs[]? == "*") | |
) | |
> 0 | |
) | |
| .metadata.name | |
] | unique' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment