-
Make sure the volume migration is successful. Follow the volume migration steps from the docs.
-
Get the yamls for old volumesnapshot and volumesnapshotdata.
- List old volumesnapshots and
mayadata:cstor$ kubectl get volumesnapshots.volumesnapshot.external-storage.k8s.io NAME AGE snapshot-demo-cstor 7s
- Select the snapshot to migrate and get the -o yaml output.
mayadata:cstor$ kubectl get volumesnapshots.volumesnapshot.external-storage.k8s.io snapshot-demo-cstor -oyaml apiVersion: volumesnapshot.external-storage.k8s.io/v1 kind: VolumeSnapshot metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"volumesnapshot.external-storage.k8s.io/v1","kind":"VolumeSnapshot","metadata":{"annotations":{},"name":"snapshot-demo-cstor","namespace":"default"},"spec":{"persistentVolumeClaimName":"demo-vol-claim-1"}} creationTimestamp: "2020-06-12T05:06:30Z" generation: 3 labels: SnapshotMetadata-PVName: pvc-dd6ad226-c2b3-47c8-a8bf-46cb820d187a SnapshotMetadata-Timestamp: "1591938390389915555" name: snapshot-demo-cstor namespace: default resourceVersion: "1356" selfLink: /apis/volumesnapshot.external-storage.k8s.io/v1/namespaces/default/volumesnapshots/snapshot-demo-cstor uid: 51cc8860-a5b6-473f-8d96-8ca8fa90f4ad spec: persistentVolumeClaimName: demo-vol-claim-1 snapshotDataName: k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 status: conditions: - lastTransitionTime: "2020-06-12T05:06:31Z" message: Snapshot created successfully reason: "" status: "True" type: Ready creationTimestamp: null
- Get the snapshotDataName from the output of previous step and get -o yaml for corresponding volumesnapshotdata.
mayadata:cstor$ kubectl get volumesnapshotdatas.volumesnapshot.external-storage.k8s.io k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 -oyaml apiVersion: volumesnapshot.external-storage.k8s.io/v1 kind: VolumeSnapshotData metadata: creationTimestamp: "2020-06-12T05:06:31Z" generation: 1 name: k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 resourceVersion: "1355" selfLink: /apis/volumesnapshot.external-storage.k8s.io/v1/volumesnapshotdatas/k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 uid: 7fb73143-5da2-4ff4-9eb8-aaf98060328e spec: openebsVolume: capacity: 5Gi snapshotId: pvc-dd6ad226-c2b3-47c8-a8bf-46cb820d187a_snapshot-demo-cstor_1591938390393273386 persistentVolumeRef: kind: PersistentVolume name: pvc-dd6ad226-c2b3-47c8-a8bf-46cb820d187a volumeSnapshotRef: kind: VolumeSnapshot name: default/snapshot-demo-cstor-51cc8860-a5b6-473f-8d96-8ca8fa90f4ad status: conditions: - lastTransitionTime: "2020-06-12T05:06:31Z" message: Snapshot created successfully reason: "" status: "True" type: Ready creationTimestamp: null
-
Make sure the volumesnapshotclass csi-cstor-snapshotclass is present
mayadata:cstor-csi$ kubectl get volumesnapshotclasses.snapshot.storage.k8s.io NAME AGE csi-cstor-snapshotclass 2m17s
If not you can use the below command.
mayadata:cstor-csi$ kubectl apply -f https://raw.githubusercontent.com/openebs/cstor-csi/master/deploy/snapshot-class.yaml
-
Create volumesnapshotcontent for the corresponding volumesnapshotdata. Get the persistentVolumeRef name and openebsVolume snapshotId from the old volumesnapshot data. For example the above volumesnapshotdata has persistentVolumeRef name as
pvc-dd6ad226-c2b3-47c8-a8bf-46cb820d187a
and openebsVolume snapshotId aspvc-dd6ad226-c2b3-47c8-a8bf-46cb820d187a_snapshot-demo-cstor_1591938390393273386
. Now we will populate the below yaml according to the comments in the yaml.apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshotContent metadata: # the name should be same the old volumesnapshotdata name: k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 spec: deletionPolicy: Delete driver: cstor.csi.openebs.io source: # the snapshotHandle should be <persistentVolumeRef name>@<openebsVolume snapshotId> snapshotHandle: pvc-dd6ad226-c2b3-47c8-a8bf-46cb820d187a@pvc-dd6ad226-c2b3-47c8-a8bf-46cb820d187a_snapshot-demo-cstor_1591938390393273386 volumeSnapshotClassName: csi-cstor-snapshotclass volumeSnapshotRef: apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshot # the name of should be same as old volumesnapshot name: snapshot-demo-cstor namespace: default
Apply the above yaml after properly configuring it.
-
Create new volumesnapshot for the corresponding old volumesnapshot. Configure the below yaml according to comments and apply it.
apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshot metadata: name: snapshot-demo-cstor namespace: default spec: source: # the volumeSnapshotContentName should be same as the name of the one created in above step. volumeSnapshotContentName: k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 volumeSnapshotClassName: csi-cstor-snapshotclass
This should bind both the volumesnapshotcontent and new volumesnapshot together.
-
Verify that the new snapshot is bound.
mayadata:setup$ kubectl get volumesnapshots.snapshot.storage.k8s.io snapshot-demo-cstor -oyaml 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":"snapshot-demo-cstor","namespace":"default"},"spec":{"source":{"volumeSnapshotContentName":"k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005"},"volumeSnapshotClassName":"csi-cstor-snapshotclass"}} creationTimestamp: "2020-06-12T05:50:42Z" finalizers: - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection - snapshot.storage.kubernetes.io/volumesnapshot-bound-protection generation: 1 name: snapshot-demo-cstor namespace: default resourceVersion: "7065" selfLink: /apis/snapshot.storage.k8s.io/v1beta1/namespaces/default/volumesnapshots/snapshot-demo-cstor uid: 382e5bec-c4f5-4dd8-a4f8-2c02a70391c1 spec: source: volumeSnapshotContentName: k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 volumeSnapshotClassName: csi-cstor-snapshotclass status: boundVolumeSnapshotContentName: k8s-volume-snapshot-7ad32bd7-ac6a-11ea-8edf-0242ac110005 creationTime: "2020-06-12T05:50:35Z" readyToUse: true restoreSize: "0"
-
Delete the old volume snapshot.
mayadata:setup$ kubectl delete volumesnapshots.volumesnapshot.external-storage.k8s.io snapshot-demo-cstor volumesnapshot.volumesnapshot.external-storage.k8s.io "snapshot-demo-cstor" deleted
Last active
June 12, 2020 05:59
-
-
Save shubham14bajpai/0845cf913e44792431b4f5d315103e46 to your computer and use it in GitHub Desktop.
Steps to migrate snapshot migration after migrating cstor volumes to CSI spec.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment