Skip to content

Instantly share code, notes, and snippets.

@scholzie
Created August 3, 2016 17:46
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 scholzie/5261e391b4219dffc7bda13877bab686 to your computer and use it in GitHub Desktop.
Save scholzie/5261e391b4219dffc7bda13877bab686 to your computer and use it in GitHub Desktop.
function kdump() {
if [[ $# -ne 0 ]]; then
ACTION="$1"
else
ACTION="get"
fi
echo "==== DUMPING KLUSTER INFO VIA ACTION: ${ACTION} ===="
if [[ "$ACTION" == "get" ]]; then
for cmd in $(kubectl get 2>&1 | awk '/\*/ {print $2}'); do
echo " === get ${cmd} (all-namespaces) ==="
kubectl get ${cmd} --all-namespaces 2> /dev/null
if [[ $? -ne 0 ]]; then
echo " === get ${cmd} (not-namespaced) ==="
kubectl get ${cmd}
fi
done
elif [[ "$ACTION" == "describe" ]]; then
for cmd in $(kubectl describe 2>&1 | awk '/\*/ {print $2}'); do
echo " === describe ${cmd}: ==="
kubectl describe ${cmd}
done
else
echo "NO ACTION $ACTION DEFINED!"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment