Knowledge Base
linbit.com Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

LINSTOR Kubernetes Backup Options

This article discusses the backup solutions that work with LINSTOR® and Kubernetes.

What Backup Systems Work with LINSTOR®?

Kasten

Reported to work by customer. Not yet tested by LINBIT®. Kasten Documentation

Velero

Tested, works. Requires S3 compatible storage. Refer to this blog post for instructions.

Stash

Not yet tested.

Trillo

Works as described here: Installing Triliovault

Backing up PVs requires snapshot support in the CSI driver that provisioned the volume. Added Helm repositories for Trilio:

helm repo add triliovault-operator http://charts.k8strilio.net/trilio-stable/k8s-triliovault-operator
helm repo add triliovault http://charts.k8strilio.net/trilio-stable/k8s-triliovault
helm repo update
helm install triliovault-operator triliovault-operator/k8s-triliovault-operator --version 0.2.0
cat << EOF > triliovault-manager.yaml
apiVersion: triliovault.trilio.io/v1alpha1
kind: TrilioVaultManager
metadata:
  labels:
    triliovault: triliovault
  name: triliovault-manager
  namespace: default
spec:
  trilioVaultAppVersion: 0.2.4
  helmVersion:
    version: v3
  applicationScope: Cluster
  #restoreNamespaces: [kube-system, default, restore-ns]
  resources:
    requests:
      memory: 400Mi
EOF
kubectl create -f triliovault-manager.yaml

Added snapshot support to Kubernetes 1.18:

git clone https://github.com/kubernetes-csi/external-snapshotter && cd external-snapshotter/
kubectl create -f config/crd
kubectl create -f deploy/kubernetes/snapshot-controller

Created a basic Ubuntu pod with a PV carved from LINSTOR (using labels app=ubuntu since Trilio uses labels to know what to backup). Created a file with my name in it:

cat << EOF > ubuntu-pod-and-vol.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ubuntu-pvc-0
  labels:
    app: ubuntu
spec:
  storageClassName: linstor-csi-lvm-thin-r1
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: ubuntu-0
  labels:
    app: ubuntu
spec:
  volumes:
    - name: ubuntu-pvc-0
      persistentVolumeClaim:
        claimName: ubuntu-pvc-0
  containers:
    - name: ubuntu-0
      image: ubuntu
      volumeMounts:
        - mountPath: /data
          name: ubuntu-pvc-0
      command: [bash]
      args: [-c, while true; do sleep 10000s; done]
EOF
kubectl apply -f ubuntu-pod-and-vol.yaml
kubectl exec -it ubuntu-0 -- bash -c “echo Matt > /data/name.txt”

Created an S3 bucket in AWS, no public access, using access keys I setup on my account. Then, created backup target and backup plan for Trilio, and took a backup:

cat << EOF > trilio-backup-plan.yaml
apiVersion: triliovault.trilio.io/v1alpha1
kind: BackupPlan
metadata:
  name: ubuntu-application
spec:
  backupConfig:
    target:
      name: ubuntu-target
    schedulePolicy:
      fullBackupCron:
        schedule: * 0 1 * *
      incrementalCron:
        schedule: * 0 * * *
  backupNamespace: default
  backupPlanComponents:
    custom:
      matchLabels:
        app: ubuntu
EOF
kubectl apply -f trilio-bucket.yaml
kubectl apply -f trilio-backup-plan.yaml

cat << EOF > trilio-backup.yaml
apiVersion: triliovault.trilio.io/v1alpha1
kind: Backup
metadata:
  name: ubuntu-backup
spec:
  type: Full
  scheduleType: OneTime
  backupPlan:
    name: ubuntu-application
EOF
kubectl apply -f trilio-backup.yaml

Once the backup completed, I deleted the Ubuntu pod and PVC, verifying everything was gone from Kubernetes and LINSTOR. Then I used the restore YAML to restore the application and verify my data was restored successfully:

cat << EOF > trilio-restore.yaml
apiVersion: triliovault.trilio.io/v1alpha1
kind: Restore
metadata:
  name: ubuntu-restore
spec:
  source:
    type: Backup
    backup:
      name: ubuntu-backup
  restoreNamespace: default
EOF

kubectl apply -f trilio-restore.yaml
kubectl exec -it ubuntu-0 -- bash -c “cat /data/name.txt”

Reviewed 2020/12/14 – DGT