1 year ago

#342831

test-img

abdelhalimresu

Migrate Kubernetes storage from vSphere to NFS with StatefulSets

I'm trying to move all my persistent volumes from vSphere to NFS, I managed to do it for many applications that use Deployment kind. All I have to do is:

  • Mount the NFS volume to a different path (/tmp for example)
  • Copy the data from vSphere volume to NFS volume (using cp command in the pod)
  • Swap the volumes names in the Deployment definition and finally get rid of the vSphere volume

Now, I have StatefulSets with volumes to be mounted on each pod. This approach won't work since Kubernetes wont let you modify the field spec.volumeClaimTemplates in StatefulSets definition.

apiVersion: apps/v1
kind: StatefulSet
...
spec:
...
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 30Gi

I have 3 replicas and the vSphere volumes were provisioned dynamically, but I have now 3 NFS volumes that I created manually and I want to migrate the existing data to them.

Any idea how to perform this operation?

kubernetes

nfs

persistent-volumes

kubernetes-statefulset

0 Answers

Your Answer

Accepted video resources