Skip to content

Commit

Permalink
feat(zfspv): adding backup and restore support (#162)
Browse files Browse the repository at this point in the history
This commit adds support for Backup and Restore controller, which will be watching for
the events. The velero plugin will create a Backup CR to create a backup
with the remote location information, the controller will send the data
to that remote location.

In the same way, the velero plugin will create a Restore CR to restore the
volume from the the remote location and the restore controller will restore
the data.

Steps to use velero plugin for ZFS-LocalPV are :

1. install velero

2. add openebs plugin

velero plugin add openebs/velero-plugin:latest

3. Create the volumesnapshot location :

for full backup :-

```yaml
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
  name: default
  namespace: velero
spec:
  provider: openebs.io/zfspv-blockstore
  config:
    bucket: velero
    prefix: zfs
    namespace: openebs
    provider: aws
    region: minio
    s3ForcePathStyle: "true"
    s3Url: http://minio.velero.svc:9000
```

for incremental backup :-

```yaml
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
  name: default
  namespace: velero
spec:
  provider: openebs.io/zfspv-blockstore
  config:
    bucket: velero
    prefix: zfs
    backup: incremental
    namespace: openebs
    provider: aws
    region: minio
    s3ForcePathStyle: "true"
    s3Url: http://minio.velero.svc:9000
```

4. Create backup

velero backup create my-backup --snapshot-volumes --include-namespaces=velero-ns --volume-snapshot-locations=aws-cloud-default --storage-location=default

5. Create Schedule

velero create schedule newschedule  --schedule="*/1 * * * *" --snapshot-volumes --include-namespaces=velero-ns --volume-snapshot-locations=aws-local-default --storage-location=default

6. Restore from backup

velero restore create --from-backup my-backup --restore-volumes=true --namespace-mappings velero-ns:ns1



Signed-off-by: Pawan <pawan@mayadata.io>
  • Loading branch information
pawanpraka1 committed Sep 8, 2020
1 parent a5e645b commit e40026c
Show file tree
Hide file tree
Showing 48 changed files with 5,148 additions and 7 deletions.
38 changes: 38 additions & 0 deletions buildscripts/generate-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,38 @@ echo '
cat deploy/yamls/zfs.openebs.io_zfssnapshots.yaml >> deploy/yamls/zfssnapshot-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfssnapshots.yaml


echo '
##############################################
########### ############
########### ZFSBackup CRD ############
########### ############
##############################################
# ZFSBackups CRD is autogenerated via `make manifests` command.
# Do the modification in the code and run the `make manifests` command
# to generate the CRD definition' > deploy/yamls/zfsbackup-crd.yaml

cat deploy/yamls/zfs.openebs.io_zfsbackups.yaml >> deploy/yamls/zfsbackup-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfsbackups.yaml


echo '
##############################################
########### ############
########### ZFSRestore CRD ############
########### ############
##############################################
# ZFSRestores CRD is autogenerated via `make manifests` command.
# Do the modification in the code and run the `make manifests` command
# to generate the CRD definition' > deploy/yamls/zfsrestore-crd.yaml

cat deploy/yamls/zfs.openebs.io_zfsrestores.yaml >> deploy/yamls/zfsrestore-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfsrestores.yaml

## create the operator file using all the yamls

echo '# This manifest is autogenerated via `make manifests` command
Expand All @@ -81,6 +113,12 @@ cat deploy/yamls/zfsvolume-crd.yaml >> deploy/zfs-operator.yaml
# Add ZFSSnapshot v1alpha1 and v1 CRDs to the Operator yaml
cat deploy/yamls/zfssnapshot-crd.yaml >> deploy/zfs-operator.yaml

# Add ZFSBackup v1 CRDs to the Operator yaml
cat deploy/yamls/zfsbackup-crd.yaml >> deploy/zfs-operator.yaml

# Add ZFSRestore v1 CRDs to the Operator yaml
cat deploy/yamls/zfsrestore-crd.yaml >> deploy/zfs-operator.yaml

# Copy the base Operator yaml to CentOS 7 and 8 Operator yamls
cp deploy/zfs-operator.yaml deploy/operators/centos7/zfs-operator.yaml
cp deploy/zfs-operator.yaml deploy/operators/centos8/zfs-operator.yaml
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/zfs-driver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FROM ubuntu:19.10
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update; exit 0
RUN apt-get -y install rsyslog libssl-dev xfsprogs ca-certificates
RUN apt-get -y install btrfs-progs
RUN apt-get -y install btrfs-progs netcat

ARG ARCH
ARG DBUILD_DATE
Expand Down
1 change: 1 addition & 0 deletions changelogs/unreleased/162-pawanpraka1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
adding velero backup and restore support
193 changes: 193 additions & 0 deletions deploy/operators/centos7/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,199 @@ status:
conditions: []
storedVersions: []


##############################################
########### ############
########### ZFSBackup CRD ############
########### ############
##############################################

# ZFSBackups CRD is autogenerated via `make manifests` command.
# Do the modification in the code and run the `make manifests` command
# to generate the CRD definition

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.8
creationTimestamp: null
name: zfsbackups.zfs.openebs.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.prevSnapName
description: Previous snapshot for backup
name: PrevSnap
type: string
- JSONPath: .status
description: Backup status
name: Status
type: string
- JSONPath: .metadata.creationTimestamp
description: Age of the volume
name: Age
type: date
group: zfs.openebs.io
names:
kind: ZFSBackup
listKind: ZFSBackupList
plural: zfsbackups
shortNames:
- zb
singular: zfsbackup
preserveUnknownFields: false
scope: Namespaced
subresources: {}
validation:
openAPIV3Schema:
description: ZFSBackup describes a zfs backup resource created as a custom resource
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ZFSBackupSpec is the spec for a ZFSBackup resource
properties:
backupDest:
description: BackupDest is the remote address for backup transfer
minLength: 1
type: string
ownerNodeID:
description: OwnerNodeID is a name of the nodes where the source volume
is
minLength: 1
type: string
prevSnapName:
description: PrevSnapName is the last completed-backup's snapshot name
type: string
snapName:
description: SnapName is the snapshot name for backup
minLength: 1
type: string
volumeName:
description: VolumeName is a name of the volume for which this backup
is destined
minLength: 1
type: string
required:
- backupDest
- ownerNodeID
- volumeName
type: object
status:
description: ZFSBackupStatus is to hold status of backup
type: string
required:
- spec
- status
type: object
version: v1
versions:
- name: v1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []


##############################################
########### ############
########### ZFSRestore CRD ############
########### ############
##############################################

# ZFSRestores CRD is autogenerated via `make manifests` command.
# Do the modification in the code and run the `make manifests` command
# to generate the CRD definition

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.8
creationTimestamp: null
name: zfsrestores.zfs.openebs.io
spec:
group: zfs.openebs.io
names:
kind: ZFSRestore
listKind: ZFSRestoreList
plural: zfsrestores
singular: zfsrestore
preserveUnknownFields: false
scope: Namespaced
validation:
openAPIV3Schema:
description: ZFSRestore describes a cstor restore resource created as a custom
resource
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ZFSRestoreSpec is the spec for a ZFSRestore resource
properties:
ownerNodeID:
description: owner node name where restore volume is present
minLength: 1
type: string
restoreSrc:
description: it can be ip:port in case of restore from remote or volumeName
in case of local restore
minLength: 1
type: string
volumeName:
description: volume name to where restore has to be performed
minLength: 1
type: string
required:
- ownerNodeID
- restoreSrc
- volumeName
type: object
status:
description: ZFSRestoreStatus is to hold result of action.
type: string
required:
- spec
- status
type: object
version: v1
versions:
- name: v1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

---

# Create the CSI Driver object
Expand Down
Loading

0 comments on commit e40026c

Please sign in to comment.