Clone
#
PrerequisitesFor clone, we need to have VolumeSnapshotDataSource
support, which is in beta in Kubernetes 1.23. If you are using the Kubernetes version less than 1.23, you have to enable the VolumeSnapshotDataSource
feature gate at kubelet and kube-apiserver.
#
Create Clone from SnapshotWe can create a clone volume from a snapshot and use that volume for some application. We can create a PVC YAML and mention the snapshot name in the datasource.
The above yaml says that create a volume from the snapshot zfspv-snap. Applying the above yaml will create a clone volume on the same node where the original volume is present. The newly created clone PV will also be there on the same node where the original PV is there. Apply the clone yaml.
note
The clone PVC should also be of the same size as that of the original volume. Currently resize is not supported. Also, note that the poolname should also be same, as across the ZPOOL clone is not supported. So, if you are using a separate storageclass for the clone PVC, make sure it refers to the same ZPOOL.
We can see in the above output that zfspv-clone claim has been created and it is bound. Also, we can check the zfs list on node and verify that clone volume is created.
The clone volume will have properties same as snapshot properties which are the properties when that snapshot has been created. The ZFSVolume object for the clone volume will be something like below:
Here you can note that this resource has Snapname field which tells that this volume is created from that snapshot.
#
Create Clone from VolumeWe can create a clone volume from an existing volume and use that volume for some application. We can create a PVC YAML and mention the source volume name from where we want to create the clone in the datasource.
The above yaml says that create a clone from the pvc zfspv-pvc as source. Applying the above yaml will create a clone volume on the same node where the original volume is present. The newly created clone PV will also be there on the same node where the original PV is there. Apply the clone yaml.
note
The clone PVC should also be of the same size as that of the original volume. Also, note that the poolname should also be same, as across the ZPOOL clone is not supported. So, if you are using a separate storageclass for the clone PVC, make sure it refers to the same ZPOOL.
We can see in the above output that zfspv-clone claim has been created and it is bound. Also, we can check the zfs list on node and verify that clone volume is created.
The clone volume will have properties same as source volume properties at the time of creating the clone. The ZFSVolume object for the clone volume will be something like below:
The Local PV ZFS driver creates an internal snapshot on the source volume with the name same as clone volume name and then creates the clone from that snapshot.
note
This resource has Snapname field which tells that this volume is created from that internal snapshot.