Skip to content

Instantly share code, notes, and snippets.

@yogeek
Created April 13, 2023 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogeek/51d39c7f3c7fe8da16d7c28b0b83b96d to your computer and use it in GitHub Desktop.
Save yogeek/51d39c7f3c7fe8da16d7c28b0b83b96d to your computer and use it in GitHub Desktop.
Kyverno reports
#!/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