Backup a Kubernetes cluster as a yaml manifest.
With this utility you can save your cluster resources as nice yaml manifests without unnecessary metadata.
Key features:
docker pull ghcr.io/woozymasta/kube-dump:1.1.1
docker pull quay.io/woozymasta/kube-dump:1.1.1
docker pull docker.io/woozymasta/kube-dump:1.1.1
Required dependencies:
kubectl
-jq
- Command-line JSON processoryq
- Command-line YAML processorOptional dependencies:
curl
- Used to check kubernetes api livez probe when use serviceaccountgit
- Used to store backups as a git repositorytar
- Used to create backup archives with one of the compression libraries:
xz
- a lossless data compression file format based on the LZMA algorithmgzip
- single-file/stream lossless data compression utilitybzip2
- compression program that uses the Burrows–Wheeler algorithm./kube-dump [command] [[flags]]
Available Commands:
all, dump Dump all kubernetes resources
ns, dump-namespaces Dump namespaced kubernetes resources
cls, dump-cluster Dump cluster wide kubernetes resources
The command can also be passed through the environment variable MODE.
All flags presented below have a similar variable in uppercase, with underscores
For example:
--destination-dir == DESTINATION_DIR
Flags:
-h, --help This help
-s, --silent Execute silently, suppress all stdout messages
-d, --destination-dir Path to dir for store dumps, default ./data
-f, --force-remove Delete resources in data directory before launch
--detailed Do not remove detailed state specific fields
--output-by-type Organize output into directories by resource type
--flat Organize all resources of the same type in the
same file
Kubernetes flags:
-n, --namespaces List of kubernetes namespaces
-r, --namespaced-resources List of namespaced resources
-k, --cluster-resources List of cluster resources
--kube-config Path to kubeconfig file
--kube-context The name of the kubeconfig context to use
--kube-cluster The name of the kubeconfig cluster to use
--kube-insecure-tls Skip check server's certificate for validity
Git commit flags:
-c, --git-commit Commit changes
-p, --git-push Commit changes and push to origin
-b, --git-branch Branch name
--git-commit-user Commit author username
--git-commit-email Commit author email
--git-remote-name Remote repo name, defualt is origin
--git-remote-url Remote repo URL
Archivate flags:
-a, --archivate Create archive of data dir
--archive-rotate-days Rotate archives older than N days
--archive-type Archive type xz, gz or bz2, default is tar
Example of use:
$cmd dump-namespaces -n default,dev -d /mnt/dump -spa --archive-type gz
All environment variables are described in the .env
file,
you can use them both for the container launch configuration and
directly from the .env
file, it is read automatically at startup.
All resources automatically discovered from the API if not pass as argument.