Created
April 13, 2023 10:16
-
-
Save MegaManSec/9900f2ce07e032f55229ca3e861b714c to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Get the list of namespaces using kubectl | |
namespaces=$(kubectl get namespaces -o custom-columns="NAME:.metadata.name" --no-headers) | |
describe_and_print() { | |
kubectl describe pod $2 > descriptions/$1/$2 | |
echo "Described '$1/$2'" | |
} | |
export -f describe_and_print | |
# Loop through each namespace | |
for namespace in $namespaces; do | |
mkdir -p descriptions/$namespace | |
# Use a namespace | |
kubectl config set-context --current --namespace="$namespace" | |
echo "Switched to namespace '$namespace'" | |
# Get pods in the current namespace | |
pods=$(kubectl get pods -o custom-columns="NAME:.metadata.name" --no-headers) | |
for pod in $pods; do | |
echo describe_and_print "$namespace" "$pod" | |
done | parallel --gnu -j20 --delay 0.1 --line-buffer | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment