A Go-based Kubernetes daemon that continuously runs inside Kubernetes clusters to collect all resources in YAML format, sanitize them, and push to a Git repository for backup and versioning.
- Kubernetes cluster with RBAC enabled
- Git repository (GitHub, GitLab, Bitbucket, etc.)
- SSH key or access token for Git authentication
# Create SSH key secret
kubectl create secret generic git-ssh-key \
--from-file=id_rsa=/path/to/your/private/key \
-n kube-systemNote: SSH host key verification is handled automatically. The application will:
- Look for existing
known_hostsfiles (/root/.ssh/known_hosts,/etc/ssh/ssh_known_hosts) - Use
SSH_KNOWN_HOSTSenvironment variable if set - Create a default
known_hostsfile with common Git service providers (GitHub, GitLab, Bitbucket)
# Create token secret
kubectl create secret generic git-token \
--from-literal=token=your-github-token \
-n kube-system# Apply RBAC configuration
kubectl apply -f k8s/rbac.yaml
# Update deployment configuration
# Edit k8s/deployment.yaml and update:
# - GIT_REPOSITORY: Your Git repository URL
# - Other environment variables as needed
# Deploy the application
kubectl apply -f k8s/deployment.yamlAll configuration is done via environment variables:
| Variable | Description | Default | Required |
|---|---|---|---|
| Git Configuration | |||
GIT_REPOSITORY |
Git repository URL | - | β |
GIT_BRANCH |
Git branch to use | main |
β |
GIT_AUTHOR_NAME |
Git commit author name | Kube Git Backup |
β |
GIT_AUTHOR_EMAIL |
Git commit author email | kube-backup@example.com |
β |
GIT_SSH_KEY_PATH |
Path to SSH private key | /root/.ssh/id_rsa |
β |
GIT_TOKEN |
Git access token | - | β |
| Backup Settings | |||
BACKUP_INTERVAL |
Backup interval (Go duration) | 1h |
β |
WORK_DIR |
Working directory for Git operations | /tmp/kube-backup |
β |
| Resource Filtering | |||
INCLUDE_RESOURCES |
Resource types to include (comma-separated) | All supported types | β |
EXCLUDE_RESOURCES |
Resource types to exclude (comma-separated) | pods,events,endpoints,replicasets |
β |
INCLUDE_NAMESPACES |
Namespaces to include (comma-separated, empty = all) | - | β |
EXCLUDE_NAMESPACES |
Namespaces to exclude (comma-separated) | kube-system,default,kube-node-lease |
β |
| YAML Processing | |||
STRIP_FIELDS |
Field paths to remove (comma-separated) | See sanitizer defaults | β |
Authentication: Automatically detected based on repository URL (HTTPS β token, SSH β key)
The backup creates an organized directory structure in your Git repository:
βββ cluster-scoped/
β βββ clusterrole/
β β βββ admin.yaml
β β βββ view.yaml
β βββ clusterrolebinding/
β βββ persistentvolume/
β βββ storageclass/
βββ namespaces/
βββ default/
β βββ deployment/
β β βββ my-app.yaml
β βββ service/
β β βββ my-app.yaml
β βββ configmap/
βββ kube-system/
βββ daemonset/
βββ service/
You can customize which fields are stripped from the YAML using the STRIP_FIELDS environment variable:
STRIP_FIELDS="metadata.uid,metadata.resourceVersion,status,spec.clusterIP,metadata.annotations[custom.io/annotation]"Supported field path formats:
- Simple paths:
metadata.uid - Nested paths:
spec.template.metadata.labels - Array fields:
spec.ports[].nodePort - Annotation keys:
metadata.annotations[key]