Docker build for kube-backup forked and modified from https://github.com/pieterlange/kube-backup
50K+
Quick 'n dirty kubernetes state backup script, designed to be ran as kubernetes Job. Think of it like RANCID for kubernetes.
Props to @gianrubio and @pieterlange for coming up with the idea and implementing them.
Use the deployment example (ssh or AWS CodeCommit authentication) and deploy a kubernetes CronJob primitive in your kubernetes (1.5 and up) cluster ensuring backups of kubernetes resource definitions to your private git repo.
Define the following environment parameters:
GIT_REPO - GIT repo url. RequiredNAMESPACES - List of namespaces to export. Default: allGLOBALRESOURCES - List of global resource types to export. Default: namespaceRESOURCETYPES - List of resource types to export. Default: ingress deployment configmap svc rc ds thirdpartyresource networkpolicy statefulset storageclass cronjob. Notice that Secret objects are intentionally not exported by default.GIT_USERNAME - Display name of git user. Default: kube-backupGIT_EMAIL - Email address of git user. Default: [email protected]GIT_BRANCH - Use a specific git branch . Default: masterChose one of two authentication mechanisms:
kops, the configuration will look something like this: additionalPolicies:
node: |
[
{
"Effect": "Allow",
"Action": [
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": "arn:aws:codecommit:<region>:<account name>:<repo-name>"
}
]
NOTE: in this deployment, the ssh volume and secret are not present.
If using a different repository (GitHub, BitBucket, etc.), mount a configured ssh directory in /backup/.ssh with the following files:
known_hosts - Preloaded with SSH host key of $GIT_REPO host.id_rsa - SSH private key of user allowed to push to $GIT_REPO.Easiest way of doing this is:
ssh-keygen -f ./id_rsa
ssh-keyscan $YOUR_GIT_HOST > known_hosts
kubectl create secret generic kube-backup-ssh -n kube-system --from-file=id_rsa --from-file=known_hosts
NOTE: If id_rsa isn't found in your ssh directory, the backup script will assume you're using AWS CodeCommit.
Optional:
spec.schedule using the cron format.spec.successfulJobsHistoryLimit and spec.failedJobsHistoryLimit.All configured resources will be exported into a directory tree structure in kind: List YAML format following a $namespace/$resourcetype.yaml file structure.
.
├── default
│ ├── configmap.yaml
│ ├── cronjob.yaml
│ ├── deployment.yaml
│ ├── ds.yaml
│ ├── ingress.yaml
│ ├── networkpolicy.yaml
│ ├── petset.yaml
│ ├── rc.yaml
│ ├── statefulset.yaml
│ ├── storageclass.yaml
│ ├── svc.yaml
│ └── thirdpartyresource.yaml
├── kube-system
│ ├── configmap.yaml
│ ├── cronjob.yaml
│ ├── deployment.yaml
│ ├── ds.yaml
│ ├── ingress.yaml
│ ├── networkpolicy.yaml
│ ├── petset.yaml
│ ├── rc.yaml
│ ├── statefulset.yaml
│ ├── storageclass.yaml
│ ├── svc.yaml
│ └── thirdpartyresource.yaml
├── prd
│ ├── configmap.yaml
│ ├── cronjob.yaml
│ ├── deployment.yaml
│ ├── ds.yaml
│ ├── ingress.yaml
│ ├── networkpolicy.yaml
│ ├── petset.yaml
│ ├── rc.yaml
│ ├── statefulset.yaml
│ ├── storageclass.yaml
│ ├── svc.yaml
│ └── thirdpartyresource.yaml
└── staging
├── configmap.yaml
├── cronjob.yaml
├── deployment.yaml
├── ds.yaml
├── ingress.yaml
├── networkpolicy.yaml
├── petset.yaml
├── rc.yaml
├── statefulset.yaml
├── storageclass.yaml
├── svc.yaml
└── thirdpartyresource.yaml
4 directories, 48 files
This is using a kubernetes alpha feature (cronjobs) and hasn't been tested for idempotency/concurrent behaviour. See the cronjob documentation for details.
If your kubernetes cluster runs under version 1.5 or less, spec.successfulJobsHistoryLimit and spec.failedJobsHistoryLimit will be ignored as they've been introduced in version 1.6. In this case, running an export every 10 minutes will quickly run up your Job (and therefor Pod) count, causing a linear increase in master server load. A fix for this is to deploy a blunt instrument to clean the old kube-backup jobs.
This project is MIT licensed.
Content type
Image
Digest
Size
55 MB
Last updated
over 9 years ago
docker pull bittorrent/kube-backup