<p>How I can mount an NFS as Alejandra(1001) user?</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: external-ns
  name: app1
  labels:
    app: app1
  annotations:
    pv.beta.kubernetes.io/gid: &quot;1001&quot;
spec:
  replicas: 1 
  selector:
    matchLabels:
      app: app1
  template:
    metadata:
      labels:
        app: app1
    spec:
      securityContext:
        runAsUser: 1001
        runAsGroup: 1001
        fsGroup: 1001
      nodeSelector:
        node-role.kubernetes.io/worker: worker 
      containers:
        - image: 192.168.1.1:5000/app1
          imagePullPolicy: Always
          name: app1
          volumeMounts:
            - mountPath: /app/var
              name: networkshared-fs-0
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: networkshared-fs-0
spec:
  capacity:
    storage: 80Gi
  accessModes:
    - ReadWriteMany
  mountOptions:
    - vers=4.0
  nfs:
    path: /var/lib/alejandra
    server: 192.168.1.2
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: alejandra-dashboard
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

</code></pre>
<p>When I do an ls I got this:</p>
<pre><code>kubectl exec -ti app1-XXX -- ls -al /var
total 12                                                                                     
drwxr-xr-x. 2 root   root   4096 Jul  1 12:48 .                                              
drwxr-xr-x. 1 alejandra alejandra 4096 Jul  2 11:20 .. 
</code></pre>
<p>The NFS server does have this /etc/exports:</p>
<p>/var/lib/alejandra 10.0.0.13/32(rw,no_root_squash,no_subtree_check)
/var/lib/alejandra 10.0.0.13/32(rw,no_root_squash,no_subtree_check)</p>
<p>Thanks</p>
<p>Updated: Same happened with hostPath.</p>

sincorchetes
<p>you would need to use a provisioner for it , take a look at , just setting up NFS is not enough , you need to add roles and rolebindings , SA etc</p>
<p><a href="https://github.com/kubernetes-sigs/nfs-ganesha-server-and-external-provisioner" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/nfs-ganesha-server-and-external-provisioner</a></p>
