Skip to content

Instantly share code, notes, and snippets.

@lbr88
Created March 9, 2023 15:23
Show Gist options
  • Save lbr88/6156b3773fe0c98b793aaa39b53f808b to your computer and use it in GitHub Desktop.
Save lbr88/6156b3773fe0c98b793aaa39b53f808b to your computer and use it in GitHub Desktop.
Export "all" resources from kubernetes to yaml. Requires kubectl plugin neat
#!/bin/bash
kubectl get -A -o custom-columns="kind":.kind,"name":.metadata.name,"namespace":.metadata.namespace pvc,configmap,serviceaccount,secret,ingress,service,deployment,statefulset,hpa,job,cronjob,replicaset --no-headers | while read kind name namespace
do
#echo $kind
#echo $namespace
#echo $name
mkdir -p "${namespace}"
echo "${namespace}:${kind}/${name}"
kubectl get -o=yaml -n "$namespace" "${kind}/${name}" |kubectl neat > "${namespace}/${kind}-${name}.yaml"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment