Skip to content

Instantly share code, notes, and snippets.

@Laxman-SM
Created March 4, 2020 09:26
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 Laxman-SM/b3287d3a23507a83a0f985dea3da049c to your computer and use it in GitHub Desktop.
Save Laxman-SM/b3287d3a23507a83a0f985dea3da049c to your computer and use it in GitHub Desktop.
print kubernetes resources
#/!bin/bash
print_kubernetes_resource() {
printf "\n\nGlobal\n======"
resource_count=$(expr $(kubectl api-resources --namespaced=false | wc -l) - 1)
resources=$(kubectl api-resources --namespaced=false | tail -n $resource_count | awk '{print $1}')
for resource in $resources; do
printf "\n\nChecking $resource...\n"
kubectl get $resource
done
printf "\n\nNamespaced\n=========="
resource_count=$(expr $(kubectl api-resources --namespaced | wc -l) - 1)
resources=$(kubectl api-resources --namespaced | tail -n $resource_count | awk '{print $1}')
for resource in $resources; do
printf "\n\nChecking $resource...\n"
kubectl get $resource --all-namespaces
done
}
print_kubernetes_resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment