Ability to clone and restore volumes across different Ceph CSI storage classes - Dev Preview
Problem Statement
- To transition a persistent volume claim (PVC) to another when Ceph cluster has pools with multiple device classes or pools with different failure-domain rules. For example, to take a volume snapshot of a PVC from rbd-ssd StorageClass, clone it to rbd-hdd, and delete the snapshot on the more expensive StorageClass.
- To take a snapshot of an image on a storage class that has lower failure-domain tolerance, and clone it to a StorageClass that has higher failure-domain tolerance.
- To reduce storage footprint.
- To move from a storage class with replica 3 to replica 2 or replica 1 there is already existing high availability or underlying storage providing resiliency.
Solution
You now have the ability to take a snapshot of a PVC created with one Ceph-CSI storage class and clone it to a PVC created using another Ceph-CSI StorageClass. The following parameters are supported for cross-storage clone or restore:
- Clonning/Restore PVC across different pool in case of RBD
- Clonning/Restore PVC across different filesystem in case of CephFS
Cloning/Restoring a PVC
Procedure
To clone/restore a PVC, you can use a StorageClass for the PVC clone other than the parent class.
- Save a YAML file similar to the following with a file name such as
pvc.yaml.
Example PVC YAML:
# pvc.yaml: 1GB volume of the rbd-ssd StorageClass
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rbd-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: rbd-ssd
- Run the following command to create the
rbd-pvc:
# oc create -f pvc.yaml
- Save a YAML file similar to the following with a file name such as
pvc-clone.yaml.
Example PVC-Clone YAML:
# pvc-clone.yaml: create a rbd-pvc-clone volume of StorageClass rbd-hdd with the data from rbd-pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rbd-pvc-clone
spec:
storageClassName: rbd-hdd
dataSource:
name: rbd-pvc
kind: PersistentVolumeClaim
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- Run the following command to create the
rbd-pvc-clone:
# oc create -f pvc-clone.yaml
As a different StorageClass is used while cloning the PVC, you can specify pool as per your requirement.
- Save a YAML file similar to the following with a file name such as
sc.yaml.
Example parent StorageClass:
# sc.yaml: rbd-ssd StorageClass using Ceph pool with only SSD devices
metadata:
name: rbd-ssd
provisioner: openshift-storage.rbd.csi.ceph.com
parameters:
clusterID: openshift-storage
pool: ocs-storagecluster-cephblockpool
- Run the following command to create the StorageClass:
# oc create -f sc.yaml
You can create your own pool with the required replica count as per your requirement. This enables you to clone or restore the volume with a set of parameters other than that of the parent volume.
The StorageClass also enables you to clone an encrypted PVC with different encryption configurations.
Example parent StorageClass with encryption:
# sc-encrypt.yaml: ...
metadata:
name: rbd-hdd
provisioner:
openshift-storage.rbd.csi.ceph.com
parameters:
clusterID: openshift-storage
pool: ocs-storagecluster-cephblockpool
encrypted: ‘true’
encryptionKMSID: vaultKMS
- Run the following command to create the new StorageClass:
# oc create -f sc-encrypt.yaml
You can change the encryptionKMSID as per your requirement.
NOTE: You can clone or restore CephFS PVC across a different file system similar to the RBD PVC example provided above.