Access files from NFS mount with service account in kubernetes pod

9/12/2019

I am looking for some help/suggestions with kubernetes. I am trying to mount an NFS shared drive to the docker container running inside a kubernetes pod so that I can access the files inside that drive from code that runs inside the docker container. I was able to successfully mount the drive and I am able to see that based on the kubectl logs for the running pod.

But my problem is that only a service account has access to the contents of the folder I need to access and I am not sure how to use the service account to access the files. I am totally new to the the kubernetes world and trying to understand and learn how this kind of scenarios are handled. I used helm charts for configuring the NFS mount.

-- Sravan Kumar
docker
docker-compose
kubernetes
kubernetes-helm
python

2 Answers

9/21/2019

You should take a look at the Security Context. More specifically, fsGroup is used to define the Volume owner.

-- Alassane Ndiaye
Source: StackOverflow

9/13/2019

So generally mounting directly inside a Docker container is not the greatest solution.

What you should rather look at when mounting data, is to create a PersistentVolume and PersistentClaim in Kubernetes and mount that to the pod. This abstract Storage specifics from your application specifics.

You can find more information on the Kubernetes blog.

In here they explain about using NFS.

-- Christiaan Vermeulen
Source: StackOverflow