kubernetes PersistenceVolume NFS IP change

Nitin Mestry asked:

We are running kubernetes on centos7 on premises from past 3years, Recently our NFS storage device was migrated to different VLAN and there was a change in IP address, now none of pods are functioning properly and waiting for PV.

My question is what is best possible way to replace old NFS server IP with new NFS server IP in PV and all PVC without loosing any data?

My answer:

First, find the name of your PV:

kubectl get pv

Then get the YAML for your PV:

kubectl get pv <name> -o yaml > pv.yaml

Now edit the NFS server address:

    server: new.server.address.example
    path: "/exported/path/example"

Finally, apply your changes:

kubectl apply -f pv.yaml

Assuming the new NFS server is reachable and Kubernetes can talk to it, your pods should begin starting up.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.