Kubernetes : Force value of "$pvname" with nfs-client-provsisioner

11/12/2019

I use nfs-client-provisioner inside my kubernetes cluster.

But, the name of the PersistentVolume is random.

cf. doc: nfs-client-provisioner

--> Persistent volumes are provisioned as ${namespace}-${pvcName}-${pvName}

But, where could i change the value of pvName ??

Actually, it's random, for exemple : pvName = pvc-2v82c574-5bvb-491a-bdfe-061230aedd5f

-- DevOpsAddict
kubernetes
nfs
persistent-volumes

1 Answer

12/10/2019

This is the naming convention of directories corresponding to the PV names but stored on share of NFS server

If it comes to PV name provisioned dynamically by nfs-provisioner it follow the following naming convention:

pvc- + claim.UID

Background information:

According to the design proposal of external storage provisioners (NFS-client belongs to this category), you must not declare volumeName explicitly in PVC spec.

# volumeName: must be empty!

pv.Name MUST be unique. Internal provisioners use name based on claim.UID to produce conflicts when two provisioners accidentally provision a PV for the same claim, however external provisioners can use any mechanism to generate an unique PV name.

In case of nfs-client provisioner, the pv.Name generation is handled by the controller library, and it gets following format:

pvc- + claim.UID

Source

I hope it helps.

-- OhHiMark
Source: StackOverflow