Commit graph

92 commits

Author SHA1 Message Date
Aman Gupta
9118f56600
chore(doc): Enhanced the doc for custom-topology support (#122)
Signed-off-by: Aman Gupta <aman.gupta@mayadata.io>
2020-05-20 14:07:44 +05:30
Pawan
2f19a6674b fix(image): updating the screneshot with new dashboard
Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-15 21:42:27 +05:30
Pawan
bd86d4cd48 chore(doc): adding 0.7.0 and 0.6.1 changelog
Also updated readme with the link to configure custom topology keys.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-15 19:47:42 +05:30
Pawan Prakash Sharma
1045f1daa1
feat(grafana): adding basic grafana dashboard (#110)
adding grafana dashboard for ZFS Local PV that shows the following metrics:

- Volume Capacity (used space percentage)
- ARC Size, Hits, Misses
- L2ARC Size, Hits, Misses
- ZPOOL Read/Write IOs
- ZPOOL Read/Write time

This dashboard was inspired by https://grafana.com/grafana/dashboards/7845

Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-15 14:39:16 +05:30
Pawan
4a92213505 fix(version): use the travis tag for the version
if there are no changes then `git describe --tags `git rev-list --tags --max-count=1`
may return older tag as there will be two tags referring to the same commit.

Using travis tag here to clearly differentiate the versions.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-14 17:56:54 +05:30
Aman Gupta
9c81ba9587
Fix the link in READme to the raw-block-volume.md file (#109)
Signed-off-by: Aman Gupta <aman.gupta@mayadata.io>
2020-05-11 09:46:23 +05:30
Pawan
2131153751 chore(import-vol): adding steps to import existing volumes to ZFS-LocalPV
Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-08 21:37:04 +05:30
Pawan
34cc65df00 chore(doc): adding raw block volume details in README
also added detailed upgrade steps.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-07 22:25:10 +05:30
Pawan
654f363b5d refact(build):trim leading v from image tag
Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-07 22:06:24 +05:30
Pawan
a8a490e9cb refact(build): make the docker images configurable
and Also trim leading v from image tag.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-07 19:18:48 +05:30
Pawan Prakash Sharma
dd059a2f43
feat(block): adding block volume support for ZFSPV (#102)
This commit adds the support for creating a Raw Block Volume request using volumemode as block in PVC :-

```
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: block-claim
spec:
  volumeMode: Block
  storageClassName: zfspv-block
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
```

The driver will create a zvol for this volume and bind mount the block device at the given path.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-05-05 12:28:46 +05:30
Pawan
49dc99726b fix(topokey): changing topology key to unique name
There are setups where nodename is different than the hostname.
The driver uses the nodename and tries to set the "kubernetes.io/hostname"
node label to the nodename. Which will fail if nodename is not same as
hostname. Here, changing the key to unique name so that the driver can set
that key as node label and also it can not modify/touch the existing node labels.

Now onwards, the driver will use "openebs.io/nodename" key to set the PV node affinity.
Old volumes will have "kubernetes.io/hostname" affinity, and they will also work as
after the PR https://github.com/openebs/zfs-localpv/pull/94, it supports all the node
labels as topology key and all the nodes have "kubernetes.io/hostname" label set. So
old volumes will work without any issue. Also for the same reason old stoarge classes
which are using "kubernetes.io/hostname" as topology key, will work as that key is supported.

This fixes the issue where the driver was trying to create the PV on the master node
as master node is having "kubernetes.io/hostname" label, so it is also becoming a valid
candidate for provisioning the PV. After changing the key to unique name, since the driver
will not run on master node, so it will not set "openebs.io/nodename" label to this node
hence this node will never become a valid candidate for the provisioning the volume.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-30 14:48:51 +05:30
Pawan Prakash Sharma
de9b302083
feat(topology): adding support for custom topology keys (#94)
This commit adds the support for use to specify custom labels to the kubernetes nodes and use them in the allowedToplogoies section of the StorageClass. 

Few notes:
- This PR depends on the CSI driver's capability to support custom topology keys. 
- label on the nodes should be added first and then deploy the driver to make it aware of
all the labels that node has. If labels are added after ZFS-LocalPV driver
has been deployed, a restart all the node csi driver agents is required so that the driver
can pick the labels and add them as supported topology keys.
- if storageclass is using Immediate binding mode and topology key is not mentioned
then all the nodes should be labeled using same key, that means:
  - same key should be present on all nodes, nodes can have different values for those keys. 
  - If nodes are labeled with different keys i.e. some nodes are having different keys, then ZFSPV's default scheduler can not effictively do the volume count based scheduling. In this case the CSI provisioner will pick keys from any random node and then prepare the preferred topology list using the nodes which has those keys defined. And ZFSPV scheduler will schedule the PV among those nodes only.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-30 14:13:29 +05:30
Pawan Prakash Sharma
f65575e447
docs(project): adding project contributing guides (#99)
Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-30 00:22:52 +05:30
Aman Gupta
02bc587c08
fix(doc , format): Fixed the formatting of ReadME file for upgrade (#98)
Signed-off-by: Aman Gupta <aman.gupta@mayadata.io>
2020-04-28 17:37:52 +05:30
Pawan
6c410553d2 feat(attach): avoid creation of volumeattachment object
k8s is very slow in attaching the volumes when dealing with the
large number of volume attachment object.

(k8s issue https://github.com/kubernetes/kubernetes/issues/84169)

The volumeattachment is not required for ZFSPV, so avoid creation
of attachment object, also removed the csi-attacher container as
this is also not needed as it acts on volumeattachment object.

k8s is very slow in attaching the volumes when dealing with the
large number of volume attachment object :

k8s issue https://github.com/kubernetes/kubernetes/issues/84169).

Volumeattachment is a CR created just to tell the watcher of it
which is csi-attacher, that it has to call the Controller Publish/Unpublish grpc.
Which does all the tasks to attach the volumes to a node for example call to the
DigitalOcean Block Storage API service to attach a created volume to a specified node.
Since for ZFSPV, volume is already present locally, nothing needs to done in Controller
Publish/Unpublish, so it is good to remove them.

so avoiding creation of attachment object in this change, also removed the csi-attacher
container as this is also not needed as it acts on volumeattachment object.

Removed csi-cluster-driver-registrar container also as it is deprecated and not needed anymore.

We are using csidriver beta CRDs so minimum k8s version required is 1.14+.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-27 20:18:42 +05:30
Filippo Bosi
95230b5434
added developer environment examples (#92)
Signed-off-by: Filippo Bosi <filippo.bosi@gmail.com>
2020-04-27 20:12:09 +05:30
Pawan
d57976e483 fix(zfspv): fixing data loss in case of pod deletion
looks like a bug in ZFS as when you change the mountpoint property to none,
ZFS automatically umounts the file system. When we delete the pod, we get the
unmount request for the old pod and mount request for the new pod. Unmount
is done by the driver by setting mountpoint to none and the driver assumes that
unmount has done and proceeded to delete the mountpath, but here zfs has not unmounted
the dataset

```
$ sudo zfs get all zfspv-pool/pvc-3fe69b0e-9f91-4c6e-8e5c-eb4218468765 | grep mount
zfspv-pool/pvc-3fe69b0e-9f91-4c6e-8e5c-eb4218468765  mounted               yes                                                                                                -
zfspv-pool/pvc-3fe69b0e-9f91-4c6e-8e5c-eb4218468765  mountpoint            none                                                                                               local
zfspv-pool/pvc-3fe69b0e-9f91-4c6e-8e5c-eb4218468765  canmount              on
```

here, the driver will assume that dataset has been unmouted and proceed to delete the
mountpath and it will delete the data as part of cleaning up for the NodeUnPublish request.

Shifting to use zfs umount instead of doing zfs set mountpoint=none for umounting the dataset.
Also the driver is using os.RemoveAll which is very risky as it will clean
child also, since the mountpoint is not supposed to have anything,
just os.Remove is sufficient and it will fail if there is anything there.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-22 23:49:30 +05:30
Pawan
280949cda4 chore(changelog): adding v0.6 changelog
Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-15 14:03:04 +05:30
Pawan
61c62cf4e7 chore(changelog): adding RC2 changelog
Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-15 14:03:04 +05:30
Pawan
c1c7ed5e26 chore(changelog): adding v0.6-RC1 changelog
Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-15 14:03:04 +05:30
Aman Gupta
7a3cbae3f1 Added readme file for upgrade scripts of refactoring CRDs
Signed-off-by: Aman Gupta <aman.gupta@mayadata.io>
2020-04-15 14:02:20 +05:30
Pawan Prakash Sharma
ae724ee096
feat(validation): adding validation for ZFSPV CR parameters (#66)
Validating few parameters for the ZFSVolume custom resource

- compression can be "on", "off", "lzjb", "gzip", "gzip-[1-9]", "zle" and "lz4"
- encryption can be "on", "off", "aes-128-ccm", "aes-192-ccm", "aes-256-ccm", "aes-128-gcm", "aes-192-gcm", and "aes-256-gcm"
- dedup can be "on" and "off"
- poolname can be string
- ownernodeid can be string
- thinprovision can be "yes" and "no"
- volumetype can be "DATASET" and "ZVOL"

Also added required fields needed to create ZFSVolume CR
- ownerNodeID
- poolname
- volumeType
- capacity


Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-14 17:26:46 +05:30
Pawan Prakash Sharma
fbd4812642
feat(zfspv): adding poolname info to the PV volumeattributes (#80)
Now PV will have poolname/parent-dataset info in volume attributes to help to identify the zpool on which PV has been created.

```
$ kubectl describe pv pvc-22d55c56-0c52-4fd5-894c-1f54c4dac5b7
Name:              pvc-22d55c56-0c52-4fd5-894c-1f54c4dac5b7
Labels:            <none>
Annotations:       pv.kubernetes.io/provisioned-by: zfs.csi.openebs.io
Finalizers:        [kubernetes.io/pv-protection]
StorageClass:      openebs-zfspv
Status:            Bound
Claim:             default/pvcname208
Reclaim Policy:    Delete
Access Modes:      RWO
VolumeMode:        Filesystem
Capacity:          4Gi
Node Affinity:
  Required Terms:
    Term 0:        kubernetes.io/hostname in [pawan-2]
Message:
Source:
    Type:              CSI (a Container Storage Interface (CSI) volume source)
    Driver:            zfs.csi.openebs.io
    VolumeHandle:      pvc-22d55c56-0c52-4fd5-894c-1f54c4dac5b7
    ReadOnly:          false
    VolumeAttributes:      openebs.io/poolname=zfspv-pool
                           storage.kubernetes.io/csiProvisionerIdentity=1586765686638-8081-zfs.csi.openebs.io
Events:                <none>
```
Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-14 08:46:35 +05:30
Pawan
3a1a8e78e6 feat(zfspv): handling unmounted volume
There can be cases where openebs namespace has been accidently deleted (Optoro case: https://mdap.zendesk.com/agent/tickets/963), There the driver attempted to destroy the dataset which will first umount the dataset and then try to destroy it, the destroy will fail as volume is busy. Here, as mentioned in the steps to recover, we have to manually mount the dataset
```
6. The driver might have attempted to destroy the volume before going down, which sets the mount as no(this strange behavior on gke ubuntu 18.04), we have to mount the dataset, go to the each node and check if there is any unmounted volume
zfs get mounted
if there is any unmounted dataset with this option as "no", we should do the below :-
mountpath=zfs get -Hp -o value mountpoint <dataset name>
zfs set mountpoint=none
zfs set mountpoint=<mountpath>
this will set the dataset to be mounted.
```

So in this case the volume will be  unmounted and still mountpoint will set to the mountpath, so if application pod is deleted later on, it will try to mount the zfs dataset, here just setting the `mountpoint` is not sufficient, as if we have unmounted the zfs dataset (via zfs destroy in this case), so we have to explicitely mount the dataset **otherwise application will start running without any persistence storage**. Here automating the manual steps performed to resolve the problem, we are checking in the code that if zfs dataset is not mounted after setting the mountpoint property, attempt to mount it.

This is not the case with the zvol as it does not attempt to unmount it, so zvols are fine.

Also NodeUnPublish operation MUST be idempotent. If this RPC failed, or the CO does not know if it failed or not, it can choose to call NudeUnPublishRequest again. So handled this and returned successful if volume is not mounted also added descriptive error messages at few places.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-09 20:53:10 +05:30
Prateek Pandey
6033789c17
feat(crd-gen): automate the CRDs generation with validations for APIs (#75)
- To generate the CRD spec `make manifest` generate then under
  deploy/yamls directory
- added a update-crd script to automate the steps to generate
  CRDs and its validation of each types

Signed-off-by: prateekpandey14 <prateek.pandey@mayadata.io>
2020-04-01 17:54:20 +05:30
Pawan Prakash Sharma
8a9ac43ab5
feat(crd): scripts to help migrating to new CRDs (#73)
The CRDs have changed from being under openebs.io to zfs.openebs.io. 

The scripts in this commit and the following steps will help users migrate existing CRDs to new CRDs and clean up older CRDs. 

# upgrade to new CRD
1. apply the crd yaml
    `$ kubectl apply -f upgrade/crd.yaml`

2. run upgrade.sh
    `$ upgrade/upgrade.sh`

3. upgrade the driver to v0.6
    `$ kubectl apply -f https://github.com/openebs/zfs-localpv/blob/v0.6.x/deploy/zfs-operator.yaml`

4. if everything looks good run the cleanup.sh, it will clean old CRs and delete the CRD
    `$ upgrade/cleanup.sh`

Signed-off-by: Pawan <pawan@mayadata.io>
2020-04-01 13:53:13 +05:30
Pawan Prakash Sharma
c4c2278d2f
refactor(crd): move CR from openebs.io to zfs.openebs.io (#70)
Changed the group name from openebs.io to zfs.openebs.io.

Now ZFS Volume CR will look like this : 
```
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: zfszvolumes.zfs.openebs.io
spec:
  group: zfs.openebs.io
  version: v1alpha1
  scope: Namespaced
  names:
    plural: zfsvolumes
    singular: zfsvolume
    kind:ZFSVolume
    shortNames:
    - zfsvol
    - zv
```

Snapshot CR will look like this :
```
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: zfssnapshots.zfs.openebs.io
spec:
  group: zfs.openebs.io
  version: v1alpha1
  scope: Namespaced
  names:
    plural: fssnapshots
    singular: zfssnapshot
    kind: ZFSSnapshot
    shortNames:
    - zfssnapshot
    - zfssnap

```


Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-30 22:12:34 +05:30
Steve Fan
3e874ffad7
Upgrade the base ubuntu package (#68)
Addresses GLIBC incompatability
Probably fixes #67

Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
2020-03-30 17:52:18 +05:30
Pawan
80e4d06860 fix(test): fixing resize flaky test case
We are comparing the desired size to the wrong field
because of that resize test is not executing correctly
and sometimes causing test case failure in travis.

The update call is failing sometimes while executing the zfs
property update test cases as for resize also the object
is getting modified. The test case will fail when object updation
happens between volume GET and UPDATE call while performing
zfs property update test case to set various properties on
ZFSVolume resource.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-26 22:57:23 +05:30
Pawan Prakash Sharma
27517c6254
fix(xfs): clearing the xfs log before generating UUID (#64)
xfs_admin command to generate the new UUID for the cloned
volume fails without returning error if there is log available
in the filesystem :

ERROR: The filesystem has valuable metadata changes in a log that needs to
be replayed.  Mount the filesystem to replay the log, and unmount it before
re-running xfs_admin.  If you are unable to mount the filesystem, then use
the xfs_repair -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.

No UUID will be generated in this case and application can not mount the volume.

Here mounting the filesystem to the temp location with "nouuid" mount option first
so that it can replay the logs first and system is in clean state and then unmount it
and after that generating the UUID with the xfs_admin command.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-26 20:52:53 +05:30
Pawan
1ed9ce525c chore(readme): adding e2e project link in README
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-21 11:23:10 +05:30
Pawan
468bf66b0c fix(xfs): fixing xfs duplicate uuid for cloned volumes
for mounting the cloned volume for xfs, a new UUID has to be generated.
We are generating a new UUID for the cloned volumes which are formatted
as xfs using xfs_admin command.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-19 12:37:29 +05:30
Pawan
1c9ee3102a feat(version): Makefile and version enhancement
Make to run go test for executing  unit test cases.

Removed version file, now if travis tag is set,
the VERSION will be set to that tag. And if travis
tag is not set, the driver version will be set to

 <branch-name>:<short commit hash>:<build date>

Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-16 20:31:43 +05:30
Pawan
4c47dcf0f5 chore(changelog): adding v0.5 changelog
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-16 14:17:08 +05:30
Pawan
b334b66223 chore(changelog): adding v0.5-RC2 changelog
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-16 14:17:08 +05:30
Pawan
0e50336bcc chore(changelog): adding v0.5-RC1 changelog
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-16 14:17:08 +05:30
Pawan
0e75d89c64 fix(clone): setting properties on the clone volume
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-12 22:03:58 +05:30
Pawan
fd2ec40fb5 chore(doc): adding resize details in README
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-06 14:02:23 +05:30
Pawan
7178387c1e feat(resize): adding BDD test for Online volume expansion
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-06 10:25:18 +05:30
Pawan
86e623a369 feat(resize): adding Online volume expansion support for ZFSPV
We can resize the volume by updating the PVC yaml to
the desired size and apply it. The ZFS Driver will take care
of updating the quota in case of dataset. If we are using a
Zvol and have mounted it as ext4 or xfs filesystem, the driver will take
care of expanding the volume via reize2fs/xfs_growfs binaries.

For resize, storageclass that provisions the pvc must suppo
rt resize. We should have allowVolumeExpansion as true in storageclass

```yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: openebs-zfspv
allowVolumeExpansion: true
parameters:
  poolname: "zfspv-pool"
provisioner: zfs.csi.openebs.io

```

Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-04 18:30:28 +05:30
Pawan
dc5edb901c feat(analytics): vendor code for google analytics
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-02 23:00:22 +05:30
Pawan
d608dbacd8 feat(analytics): adding google analytics for ZFSPV
Whenever a volume is provisioned and de-provisioned we will send a google event with mainly following details :
1.    pvName (will shown as app title in google analytics)
2.    size of the volume
3.    event type : volume-provision, volume-deprovision
4.    storage type zfs-localpv
5.    replicacount as 1
6.    ClientId as default namespace uuid

Apart from this, we send the event once in 24 hr, which will have some info like number of nodes, node type, kubernetes version etc.

This metric is cotrolled by OPENEBS_IO_ENABLE_ANALYTICS env. We can set it to false if we don't want to send the metrics.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-02 23:00:22 +05:30
Pawan
0fc86d843b chore(doc): updating readme with snapshot and clone details
Signed-off-by: Pawan <pawan@mayadata.io>
2020-03-01 00:30:22 +05:30
Aman Gupta
5922ebe038
add(doc): Adding the list of e2e test cases (#50)
Added the list of automated and manual e2e test cases specific to zfs-localpv 

Signed-off-by: Aman Gupta <aman.gupta@mayadata.io>
2020-02-28 22:33:22 +05:30
prateekpandey14
c2f22025b0 fix(operator): update provisioner image to support snapshot datasource
changes fix the zfs operator yaml with 1.5.0 csi-provisioner
image to support volumesnapshot as datasource type to
create clone volumes.

Signed-off-by: prateekpandey14 <prateekpandey14@gmail.com>
2020-02-14 00:10:07 +05:30
Pawan
638d8ae4e4 chore(doc): adding v0.4 changelog in the repo
Signed-off-by: Pawan <pawan@mayadata.io>
2020-02-13 14:51:44 +05:30
Pawan
48b7a02ccd refactor(version): bumping the version to 0.5
Signed-off-by: Pawan <pawan@mayadata.io>
2020-02-13 14:51:24 +05:30
Pawan Prakash Sharma
287606b78a
feat(zfspv): adding snapshot and clone support for ZFSPV (#39)
This commits support snapshot and clone commands via CSI driver. User can create snap and clone using the following steps. 

Note:
- Snapshot is created via reconciliation CR
- Cloned volume will be on the same zpool where the snapshot is taken
- Cloned volume will have same properties as source volume. 

-----------------------------------
Create a Snapshotclass
```
kind: VolumeSnapshotClass
apiVersion: snapshot.storage.k8s.io/v1beta1
metadata:
  name: zfspv-snapclass
  annotations:
    snapshot.storage.kubernetes.io/is-default-class: "true"
driver: zfs.csi.openebs.io
deletionPolicy: Delete
```
Once snapshotclass is created, we can use this class to create a Snapshot 
```
apiVersion: snapshot.storage.k8s.io/v1beta1
kind: VolumeSnapshot
metadata:
  name: zfspv-snap
spec:
  volumeSnapshotClassName: zfspv-snapclass
  source:
    persistentVolumeClaimName: csi-zfspv
```
```
$ kubectl get volumesnapshot
NAME          AGE
zfspv-snap    7m52s
```
```
$ kubectl get volumesnapshot -o yaml
apiVersion: v1
items:
- apiVersion: snapshot.storage.k8s.io/v1beta1
  kind: VolumeSnapshot
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"snapshot.storage.k8s.io/v1beta1","kind":"VolumeSnapshot","metadata":{"annotations":{},"name":"zfspv-snap","namespace":"default"},"spec":{"source":{"persistentVolumeClaimName":"csi-zfspv"},"volumeSnapshotClassName":"zfspv-snapclass"}}
    creationTimestamp: "2020-01-30T10:31:24Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
    - snapshot.storage.kubernetes.io/volumesnapshot-bound-protection
    generation: 1
    name: zfspv-snap
    namespace: default
    resourceVersion: "30040"
    selfLink: /apis/snapshot.storage.k8s.io/v1beta1/namespaces/default/volumesnapshots/zfspv-snap
    uid: 1a5cf166-c599-4f58-9f3c-f1148be47fca
  spec:
    source:
      persistentVolumeClaimName: csi-zfspv
    volumeSnapshotClassName: zfspv-snapclass
  status:
    boundVolumeSnapshotContentName: snapcontent-1a5cf166-c599-4f58-9f3c-f1148be47fca
    creationTime: "2020-01-30T10:31:24Z"
    readyToUse: true
    restoreSize: "0"
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
```


Openebs resource for the created snapshot 
```
$ kubectl get snap -n openebs -o yaml
apiVersion: v1
items:
- apiVersion: openebs.io/v1alpha1
  kind: ZFSSnapshot
  metadata:
    creationTimestamp: "2020-01-30T10:31:24Z"
    finalizers:
    - zfs.openebs.io/finalizer
    generation: 2
    labels:
      kubernetes.io/nodename: pawan-2
      openebs.io/persistent-volume: pvc-18cab7c3-ec5e-4264-8507-e6f7df4c789a
    name: snapshot-1a5cf166-c599-4f58-9f3c-f1148be47fca
    namespace: openebs
    resourceVersion: "30035"
    selfLink: /apis/openebs.io/v1alpha1/namespaces/openebs/zfssnapshots/snapshot-1a5cf166-c599-4f58-9f3c-f1148be47fca
    uid: e29d571c-42b5-4fb7-9110-e1cfc9b96641
  spec:
    capacity: "4294967296"
    fsType: zfs
    ownerNodeID: pawan-2
    poolName: zfspv-pool
    status: Ready
    volumeType: DATASET
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
```

Create a clone volume
    
 We can provide a datasource as snapshot name to create a clone volume
    
```yaml
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: zfspv-clone
    spec:
      storageClassName: openebs-zfspv
      dataSource:
        name: zfspv-snap
        kind: VolumeSnapshot
        apiGroup: snapshot.storage.k8s.io
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 4Gi
```
It will create a ZFS clone volume from the mentioned snapshot and create the PV on the same node where original volume is there.
    
Here, As resize is not supported yet, the clone PVC size should match the size of the snapshot.
Also, all the properties from the storageclass will not be considered for the clone case, it will take the properties from the snapshot and create the clone volume. One thing to note here is that, the storageclass in clone PVC should have the same poolname as that of the original volume as across the pool, clone is not supported.


Signed-off-by: Pawan <pawan@mayadata.io>
2020-02-13 13:31:17 +05:30
Pawan
b0434bb537 fix(zfspv): do not destroy the dataset with -R option
With "zfs destroy -R" we will delete snapshot and clones also. We should
not use that for deleting the volumes.

Signed-off-by: Pawan <pawan@mayadata.io>
2020-01-31 13:12:57 +05:30