Created
November 27, 2020 00:54
-
-
Save addodelgrossi/456bcc761f0f1e9b490b98ae3abc6cbe to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
echo "listing namespaces" | |
BACKUP_PATH=backup | |
NAMESPACES=$(kubectl get namespace | awk '{print $1}' | tail -n +2) | |
# RESOURCES="$(kubectl api-resources \ | |
# --namespaced \ | |
# --verbs list \ | |
# -o name \ | |
# | tr '\n' ,)" | |
RESOURCES="configmaps,endpoints,events,limitranges,persistentvolumeclaims,podtemplates,replicationcontrollers,resourcequotas,secrets,serviceaccounts,services,challenges.acme.cert-manager.io,orders.acme.cert-manager.io,controllerrevisions.apps,daemonsets.apps,deployments.apps,replicasets.apps,statefulsets.apps,horizontalpodautoscalers.autoscaling,cronjobs.batch,jobs.batch,certificaterequests.cert-manager.io,certificates.cert-manager.io,issuers.cert-manager.io,leases.coordination.k8s.io,endpointslices.discovery.k8s.io,events.events.k8s.io,ingresses.extensions,pods.metrics.k8s.io,ingresses.networking.k8s.io,networkpolicies.networking.k8s.io,poddisruptionbudgets.policy,rolebindings.rbac.authorization.k8s.io,roles.rbac.authorization.k8s.io,securitygrouppolicies.vpcresources.k8s.aws" | |
mkdir -p $BACKUP_PATH | |
rm -f $BACKUP_PATH/*.yml | |
for ns in $NAMESPACES | |
do | |
of="${BACKUP_PATH}/${ns}.yml" | |
echo "exporting namespace ${ns} to file ${of}" | |
kubectl get ${RESOURCES} -n ${ns} -o yaml > ${of} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment