<p>I am trying to create a NFS sidecar for Kubernetes.  The goal is to be able to mount an NFS volume to an existing pod without affecting performance.  At the same time, I want to be able to mount the same NFS volume onto another pod or server (read-only perhaps) in order to view the content there.  Has anyone tried this?  Do anyone have the procedure?</p>

ntype0076
<p>Rather than use a sidecar I would suggest using a <code>PersistentVolume</code> which uses the NFS driver and <code>PersistentVolumeClaim</code>. If you use the <code>RWX</code>/<code>ReadWriteMany</code> access mode, you'll be able to mount the share into multiple pods.</p>

<p>For examplen the <code>pv</code>: </p>

<pre><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: mypv
spec:
  capacity:
    storage: 2Gi
  nfs:
    server: my.nfs.server
    path: /myshare
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Recycle
</code></pre>

<p>the <code>pvc</code>:</p>

<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 2Gi
</code></pre>

<p>and mounted in a <code>pod</code>:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
    - name: myfrontend
      image: nginx
      volumeMounts:
      - mountPath: "/var/www/html"
        name: mypd
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: myclaim
</code></pre>

<p><a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Kubernetes Docs on Persistent Volumes</a></p>
