Categorygithub.com/mattmattox/kubebackup
modulepackage
0.0.0-20241216072918-d44934f9eac9
Repository: https://github.com/mattmattox/kubebackup.git
Documentation: pkg.go.dev

# README

KubeBackup Logo

Build, Test and Publish

Go Report Card

Docker Pulls

GitHub release (latest by date)

License

What is KubeBackup?

KubeBackup is a tool for backing up the configuration files in a Kubernetes cluster and uploading them to a S3 bucket.

How does KubeBackup work?

KubeBackup accesses the Kubernetes API from inside a container. Inside that container, a script exports all the cluster and namespace yaml files. These files can be used to redeploy an environment. All the exported yaml files are compressed and uploaded to an S3 Bucket.

Install

Install / Upgrade

helm repo add SupportTools https://charts.support.tools
helm repo update
helm upgrade --install kubebackup SupportTools/kubebackup \
--set s3.region="us-east-2" \
--set s3.bucket="my-bucket" \
--set s3.folder="my-cluster" \
--set s3.accessKey="S3_ACCESS_KEY_GOES_HERE" \
--set s3.secretKey="S3_SECRET_KEY_GOES_HERE"

How it works

KubeBackup is a helm chart that deploys a pod. This will take a YAML backup of your cluster and upload it to an S3 bucket.

The script connects to the Kubernetes API using either the provided kubeconfig file or the in-cluster configuration, if available. It then retrieves the list of available API resources and iterates through them to fetch namespaced and cluster-scoped objects.

Namespaced objects are grouped by namespace and saved in the namespace-scoped/<namespace>/<object> directory, while cluster-scoped objects are saved in the cluster-scoped/<object> directory. The output files are named .yaml.

Configuration

The following table lists the configurable parameters of the KubeBackup chart and their default values.

Environment Variables

Environment VariableDescriptionDefault Value
DEBUGEnable debug modefalse
LOG_LEVELLogging level (e.g., info, debug)info
KUBECONFIGPath to Kubernetes config~/.kube/config
BACKUP_DIRDirectory for storing backups temporarily/tmp
BACKUP_INTERVALBackup interval in seconds12
RETENTIONRetention period in days for backups in S330
S3_BUCKETS3 bucket name
S3_FOLDERFolder path within the S3 bucket
S3_ACCESS_KEY_IDS3 access key
S3_SECRET_ACCESS_KEYS3 secret key
S3_REGIONS3 region
S3_ENDPOINTCustom S3 endpoint
S3_DISABLE_SSLDisable SSL verification (true or false)false
S3_CUSTOM_CA_PATHPath to custom CA certificate file
METRICS_PORTMetrics server port9000

Building the script from source

To build the script from source, you will need to have the following installed:

To build the script, run the following commands:

git clone
cd kubebackup
make build

Contributing

If you would like to contribute to this project, please fork the repo and submit a pull request.

License

This project is licensed under the Apache License - see the LICENSE file for details.

# Packages

No description provided by the author