Scripts to export all kubernetes manifests from your cluster.
This comes in handy when you want to migrate a cluster, or use a gitbased config management tool such as kpt-config-sync or Anthos Config Management
Ensure that you have kubectl and are on the correct context for the cluster you want to export
You will need kubectl neat
, this cleans the manifest files from excess metadata.
kubectl krew install neat
Visit the kubectl-neat repo page for more information on kubectl-neat.
./nonnamespacebackup.sh
- Creates a folder named cluster
- Grabs all non-namespaced api resources
- Iterates through the resources to get names per resource
- Iterates through named resources and grabs the yaml output piping through
kubectl neat
- Saves the yaml file to
cluster/[resource]/[resource name].yaml
./namespacebackup.sh
- Creates a folder named namespaces
- Grabs all namespaced api resources
- Grabs all namespaces
- Iterates through each namespace
- Iterates through the resources to get names per resource
- Iterates through named resources and grabs the yaml output piping through
kubectl neat
- Saves the yaml file to
namespaces/[namespace name]/[resource]/[resource name].yaml
Note some kube api resources are deprecated/cannot be gotten with the kubectl get command.