Ceph
PLEASE NOTE: This document applies to v1.7 version and not to the latest stable release v1.9
Flex to CSI Migration
In Rook v1.8, the Flex driver has been deprecated. Before updating to v1.8, any Flex volumes created in previous versions of Rook will need to be converted to Ceph-CSI volumes.
The tool persistent-volume-migrator will help automate migration of Flex rbd volumes to Ceph-CSI volumes.
Note Migration of CephFS FlexVolumes is not supported for now.
Migration Preparation
- Rook v1.7.9 or later v1.7.x version is required. If you have a previous version of Rook running, follow the upgrade guide to upgrade from previous releases until on the latest v1.7.x.
- Enable the CSI driver if not already enabled. See the operator settings such as
ROOK_CSI_ENABLE_RBD
. - Confirm the Rook-Ceph cluster is healthy (
ceph status
showshealth: OK
) - Create the CSI storage class to which you want to migrate
- Create the migrator pod
1)
kubectl create -f cluster/examples/kubernetes/ceph/flex-migrator.yaml
NOTE: The Migration procedure will come with a downtime as we need to scale down the applications using the volumes before migration.
Migrate a PVC
- Stop the application pods that are consuming the flex volume(s) that need to be converted. For example, scale the application deployment down to 0:
kubectl scale --replicas=0 deploy/<name>
- Connect to migration pod
-
migration_pod=$(kubectl -n rook-ceph get pod -l app=rook-ceph-migrator -o jsonpath='{.items[*].metadata.name}')
-
kubectl -n rook-ceph exec -it "$migration_pod" -- sh
-
- Run the tool to migrate the PVC. See the section below for more details on the options and the sample output.
pv-migrator --pvc=<pvc-name> --pvc-ns=<pvc-namespace> --destination-sc=<storageclass-name-to-migrate-in>
- Start the application pods which were stopped in step 1. For example, scale the application deployment back up:
kubectl scale --replicas=1 deploy/<name>
Migration Tool Options
These are the options for converting a single PVC. For more options, see the tool documentation, for example to convert all PVCs automatically that belong to the same storage class.
--pvc
: required: name of the pvc to migrate--pvc-ns
: required: namespace in which the target PVC is present.--destination-sc
: required: name of the ceph-csi storage class in which you want to migrate. The destination StroageClass pool name should be same as PVC you want to migrate.--rook-ns
: optional namespace where the rook operator is running. default: rook-ceph.--ceph-cluster-ns
: optional namespace where the ceph cluster is running. default: rook-ceph.
pv-migrator --pvc=rbd-pvc --pvc-ns=default --destination-sc=csi-rook-ceph-block
I1125 07:56:22.247311 63 log.go:34] Create Kubernetes Client
I1125 07:56:22.259115 63 log.go:34] List all the PVC from the source storageclass
I1125 07:56:22.261205 63 log.go:34] 1 PVCs found with source StorageClass
I1125 07:56:22.261221 63 log.go:34] Start Migration of PVCs to CSI
I1125 07:56:22.261226 63 log.go:34] migrating PVC "rbd-pvc" from namespace "default"
I1125 07:56:22.261229 63 log.go:34] Fetch PV information from PVC rbd-pvc
I1125 07:56:22.266734 63 log.go:34] PV found "pvc-30a01887-8821-4baf-835c-16a7e55ba7f0"
---
I1125 07:56:26.483172 63 log.go:34] successfully renamed volume csi-vol-2f8de58f-4dc5-11ec-a130-0242ac110005 -> pvc-30a01887-8821-4baf-835c-16a7e55ba7f0
I1125 07:56:26.483194 63 log.go:34] Delete old PV object: pvc-30a01887-8821-4baf-835c-16a7e55ba7f0
I1125 07:56:26.504578 63 log.go:34] waiting for PV pvc-30a01887-8821-4baf-835c-16a7e55ba7f0 in state &PersistentVolumeStatus{Phase:Bound,Message:,Reason:,} to be deleted (0 seconds elapsed)
I1125 07:56:26.702921 63 log.go:34] deleted persistent volume pvc-30a01887-8821-4baf-835c-16a7e55ba7f0
I1125 07:56:26.702944 63 log.go:34] successfully migrated pvc rbd-pvc
I1125 07:56:26.703335 63 log.go:34] Successfully migrated all the PVCs to CSI
After running above command you should see something similar to this output.
Cleanup Guide
Delete the flex-migration.yaml
when done using migration tool.
kubectl delete -f cluster/examples/kubernetes/ceph/flex-migrator.yaml