Documentation/Storage-Configuration/Block-Storage-RBD/app-migration.md
When there are multiple Kubernetes clusters that are configured to connect to the same external Ceph cluster, the applications running in each K8s cluster will be storing the data in the same central Ceph cluster. In this setup, applications can be migrated to another cluster without requiring any data movement. For example, an application may need to migrate if one application cluster is becoming overloaded or if there is an outage in a cluster.
Consider the following diagram to illustrate two applications available for migration:
The external Ceph cluster stores the data, thus no data movement is necessary when the applications are migrated.
Configuring an application to migrate between clusters requires the following:
After creating the application, there will be a PV that is bound to the application's PVC. Find which PV is bound to the application's PVC. For example:
# replace "rbd-pvc" with the actual pvc name
$ kubectl get pvc rbd-pvc -o yaml | grep volumeName
volumeName: pvc-2dc3e161-bda2-4b42-956a-42a69a717979
Retrieve the PV and save to a file:
# This command removes the cluster-specific `uid` and `resourceVersion` fields
kubectl get pv pvc-2dc3e161-bda2-4b42-956a-42a69a717979 -o yaml | egrep -v " uid: | resourceVersion: " > application-pv.yaml
Now the PV can be created in another cluster when the application needs to be migrated.
!!! tip The PV could be backed up with tools such as Velero. This doc is only attempting to show how the application can be migrated without external tools.
!!! tip
Consider provisioning volmes from a storage class with reclaimPolicy: Retain to prevent
accidental deletion of a volume in one cluster while the other cluster is still consuming
the volume.
When the application needs to be migrated to another cluster:
claimRef.kubectl create -f application-pv.yaml