Last active
May 28, 2024 15:09
-
-
Save fl64/6ef8b42dc07f16264cc902b79791147d to your computer and use it in GitHub Desktop.
find all kubevirt and cdi resources
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
#!/usr/bin/env bash | |
query_meta=' | |
.items[] | |
| select( | |
(.metadata // {} | tojson | test("(kubevirt|cdi)") ) | |
) | |
| | |
{ | |
kind: .kind, | |
apiVersion: .apiVersion, | |
name: .metadata.name, | |
ns: .metadata.namespace, | |
} | |
' | |
skip_api_regex="(events|endpoints|podmetrics)" | |
collect() { | |
for api in ${1}; do | |
if [[ "${api}" =~ ${skip_api_regex} ]]; then | |
continue; | |
fi | |
result=$(kubectl get ${api} -A -o=json 2>/dev/null | jq "${query_meta}") | |
if [[ $result != "" ]]; then | |
echo ${result} | jq -c | |
fi | |
done | |
} | |
res=$(kubectl api-resources -o name) | |
collect "${res}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment