gitbackup

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 11 Imported by: 0

README

Git Backup Operator

A Kubernetes Operator for scheduled backup of Git repositories.

Overview

  1. You create a Repository resource.
  2. The controller creates a CronJob resource from it.
  3. The CronJob does the actual work.
apiVersion: gitbackup.ebiiim.com/v1beta1
kind: Repository
metadata:
  name: repo1
spec:
  src: https://github.com/ebiiim/gitbackup
  dst: https://gitlab.com/ebiiim/gitbackup
  schedule: "0 6 * * *"
  gitCredentials:
    name: repo1-secret # specify a Secret resource in the same namespace

Getting Started

Installation
  1. Make sure you have cert-manager installed, as it is used to generate webhook certificates.
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.0/cert-manager.yaml
  1. Install the controller with the following command. It creates gitbackup-system namespace and deploys CRDs, controllers and other resources.
kubectl apply -f https://github.com/ebiiim/gitbackup/releases/download/v0.1.0/gitbackup.yaml
Deploy a Repository resource
  1. Create a Secret resource that contains .git-credentials.
kubectl create secret generic repo1-secret --from-file=$HOME/.git-credentials
  1. Create a Repository resource.
apiVersion: gitbackup.ebiiim.com/v1beta1
kind: Repository
metadata:
  name: repo1
spec:
  src: https://github.com/ebiiim/gitbackup
  dst: https://gitlab.com/ebiiim/gitbackup
  schedule: "0 6 * * *"
  gitCredentials:
    name: repo1-secret
  1. Confirm that resources has been created.
$ kubectl get repos
NAME    AGE
repo1   5s

$ kubectl get cronjobs
NAME              SCHEDULE    SUSPEND   ACTIVE   LAST SCHEDULE   AGE
gitbackup-repo1   0 6 * * *   False     0        <none>          5s

Note: You can test the CronJob by manually triggering it.

kubectl create job --from=cronjob/<name> <job-name>
Uninstallation
  1. Delete all Repository resources.
kubectl delete --all repos -A
  1. Delete the Operator.
kubectl apply -f https://github.com/ebiiim/gitbackup/releases/download/v0.1.0/gitbackup.yaml

Developing

This Operator uses Kubebuilder, so we basically follow the Kubebuilder way. See the Kubebuilder Documentation for details.

Note: You can run it with KIND with the following command.

./hack/dev-kind-reset-cluster.sh
./hack/dev-kind-deploy.sh

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1beta1
Package v1beta1 contains API Schema definitions for the gitbackup v1beta1 API group +kubebuilder:object:generate=true +groupName=gitbackup.ebiiim.com
Package v1beta1 contains API Schema definitions for the gitbackup v1beta1 API group +kubebuilder:object:generate=true +groupName=gitbackup.ebiiim.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL