Skip to content

Instantly share code, notes, and snippets.

@shcallaway
Created September 24, 2019 23:32
Show Gist options
  • Select an option

  • Save shcallaway/870508a76988bc3455196b2243286c1f to your computer and use it in GitHub Desktop.

Select an option

Save shcallaway/870508a76988bc3455196b2243286c1f to your computer and use it in GitHub Desktop.
List all resource and subresource types available in a Kubernetes cluster
#!/bin/sh
# Source: https://medium.com/@tannhauser.sphinx/bash-kubernetes-script-to-list-all-available-resources-subresources-c65a5c2c1173
_list=($(kubectl get --raw / |grep "^ \"/api"|sed 's/[",]//g'));
for _api in ${_list[@]}; do
_aruyo=$(kubectl get --raw ${_api} | jq .resources);
if [ "x${_aruyo}" != "xnull" ]; then
echo;
echo "===${_api}===";
kubectl get --raw ${_api} | jq -r ".resources[].name";
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment