It may sooner or later be necessary to provide a way to migrate volumes from csi-lvm to csi-driver-lvm.
Idea: provide a tool, like others do, e.g.: tridenctl upgrade volume <name-of-trident-volume>
Following manually executed flow workes:
(DO NOT USE THIS EXAMPLE. I might be full of bugs)
These steps should better be done by a cli migration tool.
0.) make sure volume is not attached to a pod (scale sts to replicas=0 or delete a standalone pod)
1.) get the name of the node where the volume is mounted on:
k get pvc lvm-pvc-linear -o jsonpath='{.metadata.annotations.volume\.kubernetes\.io/selected-node}' && echo
shoot--ph2j95--mwen2-default-worker-579867dc45-w6r6c
2.) find pv for the given pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
lvm-pvc-linear Bound pvc-47b80ab6-e98f-4ff1-bdc1-f4f739e2e281 10Mi RWO csi-lvm 2m7s
3.) set reclaimPolicy to retain:
k patch pv pvc-47b80ab6-e98f-4ff1-bdc1-f4f739e2e281 -p '{"spec": {"persistentVolumeReclaimPolicy": "Retain"}}'
k get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-47b80ab6-e98f-4ff1-bdc1-f4f739e2e281 10Mi RWO Retain Bound default/lvm-pvc-linear csi-lvm 4m25s
4.) delete old pvc and replace with new pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: lvm-pvc-linear
namespace: default
- annotations:
- csi-lvm.metal-stack.io/type: "linear"
spec:
accessModes:
- ReadWriteOnce
- storageClassName: csi-lvm
+ storageClassName: csi-lvm-sc-linear
resources:
requests:
- storage: 10Mi
+ storage: 1Mi # small dummy value, will be resized later
5.) force the actual creation of the volume on the target node (i.e. create a pod on that node which claims the pvc), e.g.
k get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-47b80ab6-e98f-4ff1-bdc1-f4f739e2e281 10Mi RWO Retain Released default/lvm-pvc-linear csi-lvm 41m
pvc-9cba4237-1e56-4f2a-9b49-ca7f94bfdb6a 1Mi RWO Delete Bound default/lvm-pvc-linear csi-lvm-sc-linear 16m
7.) rename the old lv to the newly created one, and change tags
8.) "resize" the pvc entry back to its original size (doesn't actually change anything, since the volume on disk already has this size)
k patch pvc lvm-pvc-linear -p '{"spec": {"resources": {"requests": { "storage": "10Mi"}}}}'
9.) start old pod/sts with updated pvc (now has the new storage class but the original content)
10.) delete the pv entry of the old, unused csi-lvm volume
k delete pv pvc-9cba4237-1e56-4f2a-9b49-ca7f94bfdb6a
Migrate volume from csi-lvm to csi-driver-lvm
It may sooner or later be necessary to provide a way to migrate volumes from csi-lvm to csi-driver-lvm.
Idea: provide a tool, like others do, e.g.:
tridenctl upgrade volume <name-of-trident-volume>
Following manually executed flow workes: (DO NOT USE THIS EXAMPLE. I might be full of bugs) These steps should better be done by a cli migration tool.
0.) make sure volume is not attached to a pod (scale sts to replicas=0 or delete a standalone pod)
1.) get the name of the node where the volume is mounted on:
2.) find pv for the given pvc
3.) set reclaimPolicy to retain:
k patch pv pvc-47b80ab6-e98f-4ff1-bdc1-f4f739e2e281 -p '{"spec": {"persistentVolumeReclaimPolicy": "Retain"}}'
4.) delete old pvc and replace with new pvc
5.) force the actual creation of the volume on the target node (i.e. create a pod on that node which claims the pvc), e.g.
6.) get volume name of the newly created volume:
7.) rename the old lv to the newly created one, and change tags
For demonstration purposes, this can be done by a job. Another way would be to exec into the corresponding csi-lvm-reviver pod.
8.) "resize" the pvc entry back to its original size (doesn't actually change anything, since the volume on disk already has this size)
k patch pvc lvm-pvc-linear -p '{"spec": {"resources": {"requests": { "storage": "10Mi"}}}}'
9.) start old pod/sts with updated pvc (now has the new storage class but the original content)
10.) delete the pv entry of the old, unused csi-lvm volume
k delete pv pvc-9cba4237-1e56-4f2a-9b49-ca7f94bfdb6a