Search code examples
kubernetesnfsglusterfs

How to mount glusterfs volume using nfs in a kubernetes cluster?


I have set up a glusterfs cluster, providing volumes for pods in kubernetes. There is no problems when mounting volume in the glusterfs way:

        "volumes": [
        {
            "name": "vol1",
            "glusterfs": {
                "endpoints": "glusterfs-cluster",
                "path": "a-gluster-vol"
            }
        }
    ]

My question is, can I use the gluster volume in nfs way? Such like

 "nfs": {
                "server": "someaddress",
                "path": "/a-gluster-vol"
            }

The pod is failedMount

50s     18s     7   {kubelet kube-node-21}          Warning     FailedMount MountVolume.SetUp failed for volume "kubernetes.io/nfs/818e0668-f7df-11e6-9f69-52540092af07-vol1" (spec.Name: "vol1") pod "818e0668-f7df-11e6-9f69-52540092af07" (UID: "818e0668-f7df-11e6-9f69-52540092af07") with: mount failed: exit status 32
Mounting command: mount
Mounting arguments: 192.168.16.180:/nfs /var/lib/kubelet/pods/818e0668-f7df-11e6-9f69-52540092af07/volumes/kubernetes.io~nfs/vol1 nfs []
Output: mount.nfs: requested NFS version or transport protocol is not supported

Solution

  • The Gluster plugin in kubernetes works on FUSE, so the mount will be happening using FUSE client when you specify "gluster" in pod spec. However if you want to use it as a NFS share , you could try "nfs" spec in pod spec, but you have to make sure the "gluster nfs" service is running in Gluster Cluster.