Kubernetes Move from Persistent Volume

9/17/2021

I have run some standard Azure IaaS kubernetes clusters for 3 years in production (~ 40 nodes). Because of recent corporate security changes and kubernetes design improvements, in particular the management of CSINodes, I decided to move back from Azure file storages to Longhorn. This scenario has been validated on other clusters.

In production, I would like to move persistent volume from an initial storage class to another one. Let's say storage_class_1 to storage_class_2.

storage_class_1 inherits from Azure File whereas storage_class_2 inherits from longhorn. Persistent volumes are dynamically generated using RabbitMQ operator.

When modifying the CRD definition, no new PV is created and old ones are still bound.

persistence:
  storageClassName: storage_class_2
  storage: 10Gi

I am looking for a way to update the PV without losing any data nor stopping the service. Any idea?

Some technical information: Kubernetes : 1.19.8 Docker : 20.10.2 RabbitMQ Cluster Operator : 1.5.0

-- Jack Admin
kubernetes
longhorn
rabbitmq

1 Answer

9/28/2021

I have finally found the right sequence:

  1. Delete one PVC because of the nature of replica sets, volumes are persistent
  2. Remove the corresponding instance
  3. Create a new PVC which refers to the new storage class
  4. The Replicaset will automaticall bind the new instance to this new PVC
  5. Do it for other replicas
-- Jack Admin
Source: StackOverflow