Created
April 13, 2023 13:59
-
-
Save yogeek/51d39c7f3c7fe8da16d7c28b0b83b96d to your computer and use it in GitHub Desktop.
Kyverno reports
This file contains hidden or 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
#!/usr/bin/env bash | |
declare -A failures | |
failures=() | |
for ns in $(kubectl get ns -l owner!="gtp" -o name) | |
do | |
NS=$(echo $ns | cut -d'/' -f2) | |
if [[ "$(kubectl get polr -n $NS 2>/dev/null | wc -l)" != "0" ]] | |
then | |
# echo | |
# echo "===========> $NS" | |
fail_nb="$(kubectl get polr polr-ns-$NS -n $NS -o json | jq -r '.results[] | select(.policy=="require-requests-limits") | select(.result=="fail") | .resources[].name' | wc -l)" | |
# echo "$fail_nb" | |
# echo | |
failures[$NS]+="$fail_nb" | |
fi | |
done | |
echo "-------------------- Final ranking ----------------" | |
for item in "${!failures[@]}" | |
do | |
echo $item ' - ' ${failures["$item"]} | |
done | sort -rn -k3 | column -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment