<p>If I run Kubernetes on a cluster of Ubuntu machines, how does NFS work inside Kubernetes when it is mounted on each of the ubuntu nodes?</p>

<p>My use case is for databases and RabbitMQ to utilize that storage available on the nodes the pods are running.</p>

<p>Do I mount that NFS as a regular volume when deploying or should I use NFS directly from a persistent volume and that way not mount NFS on the Ubuntu nodes? How does the NFS work to distinguish the instances running, are the volume claim separate based on the pods/containers?</p>

<p>For you to use <code>NFS</code> with Kubernetes you have to create a <code>PV</code> and then utilize it via <code>PVC</code>.</p>

<p>Your <code>PV</code>s will decide which <code>NFS</code> node they are backed with. Since that is where you will mention the server address. Look at the sample example below.</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv0003
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  storageClassName: slow
  nfs:
    path: /tmp
    server: 172.17.0.2
</code></pre>

<p>Now if you want some pods to use storage from specific <code>PV</code> you can add a field in <code>PVC</code> called <code>volumeName</code> which basically asks the <code>PVC</code> to be bound to that <code>PV</code>.</p>

<p>The way generally people do things are set up dedicated nodes for storage, since they don't want to loose the data. Keeping data on the nodes might be risky. Since if the node goes down you loose all your data on that node, unless that is backed up somewhere.</p>

<p>Read more about the Persistent Volumes <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">here</a>.</p>
