[GlusterFS dynamic Provisioner] Custom volume name support for dynamically provisioned GlusterFS PVs in Kubernetes/Openshift

Why custom volume name for dynamically provisioned PVs? I asked the same question to community users who requested this feature and the answer was, it helps a lot to filter the gluster volume names which are serving as persistent volumes. True, if there are any number of volumes say ~1000 volumes in your cluster figuring out which volume belongs to which storage class or which project or PVC ..etc seems extremely difficult. The grouping of volume names is required for different use cases or maintenance activities.

The custom volume name support for GlusterFS PVs helps to filter glusterfs volumes which are serving persistent storage for application pods in kubernetes/openshift based on any of the below:

*) “Any string” you have given in GlusterFS Storage Class Yaml for attribute called “volumenameprefix”.
*) Based on “PVC” name
*) Based on “NAMESPACE/PROJECT” name in your kubernetes/Openshift Cluster

Once this feature is enabled, gluster volumes are provisioned in below format:

`volumenameprefix_namespace_pvcname_uuid`

`volumenameprefix` can be “ANY” string you want , it can be “storageclass name” or any string like “dept-dev”, “cns-gold” or anything!

Demo :

Even though its pretty clear from demo how this can be used, I am providing the snips here:

Create a storage class, the interesting or new field here is volumenameprefix: “dept-dev”

[terminal]
[root@localhost cluster]# cat ../demo/glusterfs-storageclass_fast.yaml
apiVersion: storage.k8s.io/v1beta1
kind: StorageClass
metadata:
name: fast
provisioner: kubernetes.io/glusterfs
parameters:
resturl: “http://127.0.0.1:8081”
restuser: “admin”
secretNamespace: “default”
secretName: “heketi-secret”
volumenameprefix: “dept-dev”
[root@localhost cluster]#

[/terminal]
Then create a PVC that points to the above storage class (fast).

[terminal]
[root@localhost cluster]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
claim1 Pending fast 46s

[root@localhost cluster]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
claim1 Bound pvc-1605d381-0b68-11e8-a4ba-c85b7636c232 8Gi RWX fast 1m
[root@localhost cluster]#
[/terminal]

[terminal]

[root@localhost cluster]# kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-1605d381-0b68-11e8-a4ba-c85b7636c232 8Gi RWX Delete Bound default/claim1 fast 4s
[root@localhost cluster]#

[/terminal]
Get more details about the PV:

[terminal]
[root@localhost cluster]# kubectl describe pv
Name: pvc-1605d381-0b68-11e8-a4ba-c85b7636c232
Labels:
Annotations: Description=Gluster-Internal: Dynamically provisioned PV
gluster.kubernetes.io/heketi-volume-id=698afa5a051d8a898e81f30c6a881182
gluster.org/type=file
kubernetes.io/createdby=heketi-dynamic-provisioner
pv.beta.kubernetes.io/gid=2200
pv.kubernetes.io/bound-by-controller=yes
pv.kubernetes.io/provisioned-by=kubernetes.io/glusterfs
volume.beta.kubernetes.io/mount-options=auto_unmount
StorageClass: fast
Status: Bound
Claim: default/claim1
Reclaim Policy: Delete
Access Modes: RWX
Capacity: 8Gi
Message:
Source:
Type: Glusterfs (a Glusterfs mount on the host that shares a pod’s lifetime)
EndpointsName: glusterfs-dynamic-claim1
Path: dept-dev_default_claim1_1606d85e-0b68-11e8-9b7a-c85b7636c232
ReadOnly: false
Events:
[/terminal]

Here dept-dev_default_claim1_1606d85e-0b68-11e8-9b7a-c85b7636c232 is the gluster volume name.

dept-dev : string given in storage class
default : namespace name
claim1 : PVC name

Lets delete this PV:

[terminal]
[root@localhost cluster]# kubectl delete pvc claim1
persistentvolumeclaim “claim1” deleted
[root@localhost cluster]#

[root@localhost cluster]# kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-1605d381-0b68-11e8-a4ba-c85b7636c232 8Gi RWX Delete Released default/claim1 fast 1m
[root@localhost cluster]# kubectl get pv
No resources found.
[root@localhost cluster]#
[/terminal]

Any feedback/suggestions/comments?