Created
March 16, 2022 22:39
-
-
Save mattmattox/73f6949fe1ecdf7644422ce69f0b2e0f to your computer and use it in GitHub Desktop.
Dump all namespaced scoped k8s objects for all namespaces
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 | |
objects=`kubectl api-resources --verbs=list --namespaced -o name` | |
for namespace in `kubectl get ns -o name | awk -F '/' '{print $2}'` | |
do | |
echo "Namespace: $namespace" | |
mkdir -p namespace/"$namespace" | |
for object in $objects | |
do | |
mkdir -p namespace/"$namespace"/"$object" | |
echo "Object: $object" | |
for item in `kubectl -n $namespace get $object -o name | awk -F '/' '{print $2}'` | |
do | |
echo "item: $item" | |
kubectl -n $namespace get $object $item -o yaml > namespace/"$namespace"/"$object"/"$item".yaml | |
done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment