How to directly mount external NFS share/volume in kubernetes(1.10.3)

7,030 views
Skip to first unread message

anupa...@gmail.com

unread,
Jun 6, 2018, 3:34:39 AM6/6/18
to Kubernetes user discussion and Q&A
HI,

I am using kubernetes : v1.10.3 , i have one external NFS server which I am able to mount to any physical machines. I want to mount this NFS directly to pod/container . I tried but every time I am getting error. don't want to use privileges, kindly help me to fix.

Even after installation of utills & common on Dokerfile RUN yum install -y nfs-utils nfs-common rpcbind nfslock still I am getting same error

ERROR: MountVolume.SetUp failed for volume "nfs" : mount failed: exit status 32 Mounting command: systemd-run Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/d65eb963-68be-11e8-8181-00163eeb9788/volumes/kubernetes.io~nfs/nfs --scope -- mount -t nfs X.X.137:/stagingfs/alt/ /var/lib/kubelet/pods/d65eb963-68be-11e8-8181-00163eeb9788/volumes/kubernetes.io~nfs/nfs Output: Running scope as unit run-43393.scope. mount: wrong fs type, bad option, bad superblock on 10.X.X.137:/stagingfs/alt/, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program) In some cases useful info is found in syslog - try dmesg | tail or so.

NFS server : mount -t nfs 10.X.X.137:/stagingfs/alt /alt

I added two things in yaml to mount NFS volume here but getting error every time.

first :

"volumeMounts": [
{
"name": "nfs",
"mountPath": "/alt"
}

],

Second :

"volumes": [
{
"name": "nfs",
"nfs": {
"server": "10.X.X.137",
"path": "/stagingfs/alt/"
}
}

],

---------------------complete yaml --------------------------------

{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "jboss",
"namespace": "staging",
"selfLink": "/apis/extensions/v1beta1/namespaces/staging/deployments/jboss",
"uid": "6a85e235-68b4-11e8-8181-00163eeb9788",
"resourceVersion": "609891",
"generation": 2,
"creationTimestamp": "2018-06-05T11:34:32Z",
"labels": {
"k8s-app": "jboss"
},
"annotations": {
"deployment.kubernetes.io/revision": "2"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"k8s-app": "jboss"
}
},
"template": {
"metadata": {
"name": "jboss",
"creationTimestamp": null,
"labels": {
"k8s-app": "jboss"
}
},
"spec": {
"volumes": [
{
"name": "nfs",
"nfs": {
"server": "10.X.X.137",
"path": "/stagingfs/alt/"
}
}

],
"containers": [
{
"name": "jboss",
"image": "my.abc.com/alt:7.1_1.1",
"resources": {},
"volumeMounts": [
{
"name": "nfs",
"mountPath": "/alt"
}

],
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent",
"securityContext": {
"privileged": true
}
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 2,
"replicas": 1,
"updatedReplicas": 1,
"readyReplicas": 1,
"availableReplicas": 1,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2018-06-05T11:35:45Z",
"lastTransitionTime": "2018-06-05T11:35:45Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2018-06-05T11:35:46Z",
"lastTransitionTime": "2018-06-05T11:34:32Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"jboss-8674444985\" has successfully progressed."
}
]
}
}

Regards Anupam Narayan

Michelle Au

unread,
Jun 6, 2018, 10:14:32 AM6/6/18
to Kubernetes user discussion and Q&A
Hi Anupan,

Mounting is done by the host machine, so the nfs-utils need to be installed on the host.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

anupa...@gmail.com

unread,
Jun 7, 2018, 12:12:42 AM6/7/18
to Kubernetes user discussion and Q&A
Hi Michelle,

Instead of mount NFS on base machine, I want to mount same directly on Pod can yo help on this ?

Thanks in advance.

Regards
Anupam

Canh Ngo

unread,
Jun 7, 2018, 2:59:11 AM6/7/18
to Kubernetes user discussion and Q&A
You can create a PersistentVolume with type NFS, set the NFS volume path there. Then you can create PVC from it and mount to any pod/deployment, etc

Michelle Au

unread,
Jun 7, 2018, 8:17:14 AM6/7/18
to Kubernetes user discussion and Q&A
Hi Anupan,

Kubernetes will mount nfs on the host machine and then make it available in your pod, however it needs the mount tools available on the host.  If you don't want to install tools on the host, then you can look into using the nfs CSI plugin instead.

Thanks,
Michelle

On Wed, Jun 6, 2018, 23:59 Canh Ngo <can...@gmail.com> wrote:
You can create a PersistentVolume with type NFS, set the NFS volume path there. Then you can create PVC from it and mount to any pod/deployment, etc

David Rosenstrauch

unread,
Jun 7, 2018, 9:41:48 AM6/7/18
to kubernet...@googlegroups.com

On 06/07/2018 12:12 AM, anupa...@gmail.com wrote:
> Hi Michelle,
>
> Instead of mount NFS on base machine, I want to mount same directly on Pod can yo help on this ?
>
> Thanks in advance.
>
> Regards
> Anupam

Set up the NFS share as a persistent volume / persistent volume claim,
then have the pod use that as its volumeMount. We have our system set
up to do this and it works great.

DR

anupa...@gmail.com

unread,
Jun 8, 2018, 1:29:25 AM6/8/18
to Kubernetes user discussion and Q&A
Hi DR,

Thanks for guide me and give idea how we can achieve same. If you have time can you please share steps to do same.

Will appreciate your help on same.

Regards
Anupam Narayan

wuxiaop...@gmail.com

unread,
Jun 8, 2018, 2:06:59 AM6/8/18
to Kubernetes user discussion and Q&A

I have the same problem, and solved by install nfs-common in every kubernetes nodes:

yum install -y nfs-utils libnfsidmap

anupa...@gmail.com

unread,
Jun 8, 2018, 5:22:58 AM6/8/18
to Kubernetes user discussion and Q&A
Hi DR,
Thanks for guide me and give idea how we can achieve same. If you have time can you please share steps to do same.

Will appreciate your help on same.

Regards
Anupam Narayan

On Thursday, 7 June 2018 19:11:48 UTC+5:30, David Rosenstrauch wrote:

David Rosenstrauch

unread,
Jun 8, 2018, 10:27:02 AM6/8/18
to kubernet...@googlegroups.com
I'm happy to answer questions about someone not knowing what the proper
approach is to doing something. But once you've been told what the
proper approach is, it's incredibly easy to search the internet to find
the specific steps on how to do it. For example, I did a google search
for "kubernetes persistent volume nfs", and the very first link that
came up was a detailed answer. You might try performing such a google
search yourself - it might help you find what you're looking for! :-)

Best,

DR

anupa...@gmail.com

unread,
Jun 11, 2018, 4:56:20 AM6/11/18
to Kubernetes user discussion and Q&A
On Thursday, 7 June 2018 12:29:11 UTC+5:30, Canh Ngo wrote:
> You can create a PersistentVolume with type NFS, set the NFS volume path there. Then you can create PVC from it and mount to any pod/deployment, etc

Thanks

it is working

anupa...@gmail.com

unread,
Jun 11, 2018, 4:58:11 AM6/11/18
to Kubernetes user discussion and Q&A
Reply all
Reply to author
Forward
0 new messages