Administrators of kubernetes clusters are faced with the task of saving the resource configuration from the namespace and transferring it to another cluster, or making a backup of an unstable test site. A one-liner script with the kubectl utility, fluently written in the terminal, copes with this task without any problems, but what if you are tired of spending a couple of minutes of time each time writing a script again. This is how the kube-dump utility appeared , in fact it is a utility that can only do one thing - to dump cluster resources.
yaml .
:
, .
, .
, .
kubernetes CronJob.
.
git .
.
.env .
:
./kube-dump dump
dev prod /dump, kubectl.
docker pull woozymasta/kube-dump:latest
docker run --tty --interactive --rm \
--volume $HOME/.kube:/.kube \
--volume $HOME/dump:/dump \
woozymasta/kube-dump:latest \
dump-namespaces -n dev,prod -d /dump --kube-config /.kube/config
CronJob
, ServiceAccount view. view, , .
CronJob ServiceAccount ClusterRoleBinding view:
kubectl create ns kube-dump kubectl -n kube-dump apply -f \ https://raw.githubusercontent.com/WoozyMasta/kube-dump/master/deploy/cluster-role-view.yaml
GitLab OAuth , :\
kubectl -n kube-dump create secret generic kube-dump \
--from-literal=GIT_REMOTE_URL=https://oauth2:$TOKEN@corp-gitlab.com/devops/cluster-bkp.git
Before installing, configure the environment variables to suit your needs, in the example, by default , the mode of copying the dev and prod namespaces is set, followed by committing the changes in the my-cluster branch and sending to the remote repository.
Set up CronJob in which we specify the frequency of the task launch:
spec:
schedule: "0 1 * * *"
Alternatively, install the example as is and then edit it:
kubectl -n kube-dump apply -f \ https://github.com/WoozyMasta/kube-dump/blob/master/deploy/cronjob-git-token.yaml kubectl -n kube-dump edit cronjobs.batch kube-dump
Plans for further development
Implement sending dumps to s3 compatible storage;
Sending notifications via email and webhook;
Git-crypt for encrypting sensitive data;
Bash / Zsh autocompletion;
OpenShift support.
I will also be glad to receive your comments and suggestions with ideas and criticism.