Giter Site home page Giter Site logo

adamdecaf / backup-controller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oliviabarrick/backup-controller

0.0 2.0 0.0 67 KB

Kubernetes operator that uses the CSI Volume Snapshot API to manage backups of your Persistent Volumes

Dockerfile 0.64% Go 94.68% Makefile 4.68%

backup-controller's Introduction

The backup-controller is a Kubernetes operator that uses the CSI Volume Snapshot API to manage backups of your Persistent Volumes.

The backup-controller works by allowing you to specify a backup frequency, retention period, and whether or not you want to automatically set the PersistentVolumeClaim to use the latest snapshot when it is created. This ensures a painless and error free workflow for managing backups of stateful services in Kubernetes.

Installation

To install, deploy the manifest:

kubectl apply -f deploy.yaml

Usage

To use, set the following annotations on any PersistentVolumeClaim that should be backed up:

  • snapshot-frequency: if set, snapshots will automatically be taken at the interval specified (as a duration: 1d6h30m).
  • snapshot-retention: if set, snapshots will automatically be deleted when they are older than the specified expiration (as a duration: 1d6h30m).
  • restore-latest: if present, when the PersistentVolumeClaim is created, the operator will automatically set the dataSource to the latest snapshot.

An example PersistentVolumeClaim:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: csi-do-test-pvc
  annotations:
    restore-latest: "true"
    snapshot-frequency: 2m
    snapshot-retention: 10m
spec:
  storageClassName: do-block-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

The backup-controller will create a snapshot of the volume every two minutes. Any snapshots older than ten minutes will be deleted.

To see snapshots, list them with kubectl:

➜  ~ kubectl get volumesnapshots
NAME                                                   AGE
csi-do-test-pvc-31fac8c7-e8b6-449c-90da-b0e8f0cd8f6d   6m
csi-do-test-pvc-3749454d-5f45-405d-b1fc-94d080f85f59   2m
csi-do-test-pvc-4d18af84-5d68-4f69-8996-f1e6fefbb724   8m
csi-do-test-pvc-e86b3ae4-2700-4b81-8e3f-30832f7076b9   4m
csi-do-test-pvc-eb9d99af-95cc-4fc2-a0af-70fe29b02729   6s
➜  ~ 

Because restore-latest is set, if the PersistentVolumeClaim is deleted and recreated it will automatically have the dataSource field set to the most recently created snapshot:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: csi-do-test-pvc
  annotations:
    restore-latest: "true"
    snapshot-frequency: 2m
    snapshot-retention: 10m
spec:
  storageClassName: do-block-storage
  accessModes:
    - ReadWriteOnce
  dataSource:
    name: csi-do-test-pvc-eb9d99af-95cc-4fc2-a0af-70fe29b02729
    kind: VolumeSnapshot
    apiGroup: snapshot.storage.k8s.io
  resources:
    requests:
      storage: 5Gi

This feature ensures that your PersistentVolumeClaims can always be restored from the most recent snapshot without any modification to the manifest (e.g., the latest snapshot id does not have to be present).

Without backup-controller, in order to restore a PersistentVolumeClaim to a snapshot it must first be deleted and then be recreated with the dataSource field set to the VolumeSnapshot to restore from. backup-controller ensures portable configuration by automatically setting the dataSource on PersistentVolumeClaims to the most recent backup using an Mutating Admission Controller.

Combined with Flux any PersistentVolumeClaim that is deleted will automatically be restored from the most recent snapshot.

To fully ensure that your snapshots are safe, also ensure that your VolumeSnapshots and VolumeSnapshotContents are backed up.

backup-controller's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.