<p>I am <a href="https://minikube.sigs.k8s.io/docs/handbook/mount/" rel="nofollow noreferrer">mounting a filesystem</a> on minikube:</p>
<pre><code>minikube mount /var/files/:/usr/share/ -p multinode-demo
</code></pre>
<p>But I found two complications:</p>
<ul>
<li>My cluster has two nodes. The pods in the first node are able to access the host files at <code>/var/files/</code>, but the pods in the second node are not. What can be the reason for that?</li>
<li>I have to mount the directory before the pods have been created. If I <code>apply</code> my deployment first, and then do the <code>mount</code>, the pods never get the filesystem. Is Kubernetes not able to apply the mounting later, over an existing deployment that required it?</li>
</ul>

<p>As mentioned in the comments section, I believe your problem is related to the following GitHub issues: <a href="https://github.com/kubernetes/minikube/issues/12165#issuecomment-895104495" rel="nofollow noreferrer">Storage provisioner broken for multinode mode</a> and <a href="https://github.com/kubernetes/minikube/issues/11765#issuecomment-868965821" rel="nofollow noreferrer">hostPath permissions wrong on multi node</a>.</p>
<p>In my opinion, you might be interested in using NFS mounts instead, and I'll briefly describe this approach to illustrate how it works.</p>
<hr />
<p>First we need to install the NFS Server and create the NFS export directory on our host:<br />
<strong>NOTE:</strong> I'm using Debian 10 and your commands may be different depending on your Linux distribution.</p>
<pre><code>$ sudo apt install nfs-kernel-server -y

$ sudo mkdir -p /mnt/nfs_share &amp;&amp; sudo chown -R nobody:nogroup /mnt/nfs_share/
</code></pre>
<p>Then, grant permissions for accessing the NFS server and export the NFS share directory:</p>
<pre><code>$ cat /etc/exports 
/mnt/nfs_share  *(rw,sync,no_subtree_check,no_root_squash,insecure)

$ sudo exportfs -a &amp;&amp; sudo systemctl restart nfs-kernel-server
</code></pre>
<p>We can use the <code>exportfs -v</code> command to display the current export list:</p>
<pre><code>$ sudo exportfs -v
/mnt/nfs_share  &lt;world&gt;(rw,wdelay,insecure,no_root_squash,no_subtree_check,sec=sys,rw,insecure,no_root_squash,no_all_squash)
</code></pre>
<p>Now it's time to create a minikube cluster:</p>
<pre><code>$ minikube start --nodes 2

$ kubectl get nodes
NAME           STATUS   ROLES                 VERSION
minikube       Ready    control-plane,master  v1.23.1
minikube-m02   Ready    &lt;none&gt;                v1.23.1
</code></pre>
<p>Please note, we're going to use the <code>standard</code> <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">StorageClass</a>:</p>
<pre><code>$ kubectl get storageclass
NAME                 PROVISIONER                RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   
standard (default)   k8s.io/minikube-hostpath   Delete          Immediate           false                 
</code></pre>
<p>Additionally, we need to find the Minikube gateway address:</p>
<pre><code>$ minikube ssh
docker@minikube:~$ ip r | grep default
default via 192.168.49.1 dev eth0 
</code></pre>
<p>Let's create <code>PersistentVolume</code> and <code>PersistentVolumeClaim</code> which will use the NFS share:<br />
<strong>NOTE:</strong> The address <code>192.168.49.1</code> is the Minikube gateway.</p>
<pre><code>$ cat pv.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-volume
spec:
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: standard
  nfs:
    server: 192.168.49.1
    path: &quot;/mnt/nfs_share&quot;

$ kubectl apply -f pv.yaml 
persistentvolume/nfs-volume created

$ cat pvc.yaml 
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: nfs-claim
  namespace: default
spec:
  storageClassName: standard
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
      
$ kubectl apply -f pvc.yaml 
persistentvolumeclaim/nfs-claim created


$ kubectl get pv,pvc
NAME                          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE
persistentvolume/nfs-volume   1Gi        RWX            Retain           Bound    default/nfs-claim   standard                71s

NAME                              STATUS   VOLUME       CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/nfs-claim   Bound    nfs-volume   1Gi        RWX            standard       56s
</code></pre>
<p>Now we can use the NFS PersistentVolume - to test if it works properly I've created <code>app-1</code> and <code>app-2</code> Deployments:<br />
<strong>NOTE:</strong> The <code>app-1</code> will be deployed on different node than <code>app-2</code> (I've specified <code>nodeName</code> in the PodSpec).</p>
<pre><code>$ cat app-1.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: app-1
  name: app-1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-1
  template:
    metadata:
      labels:
        app: app-1
    spec:
      containers:
      - image: nginx
        name: nginx
        volumeMounts:
        - name: app-share
          mountPath: /mnt/app-share
      nodeName: minikube 
      volumes:
      - name: app-share
        persistentVolumeClaim:
          claimName: nfs-claim
          

$ kubectl apply -f app-1.yaml 
deployment.apps/app-1 created

$ cat app-2.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: app-2
  name: app-2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-2
  template:
    metadata:
      labels:
        app: app-2
    spec:
      nodeName: minikube
      containers:
      - image: nginx
        name: nginx
        volumeMounts:
        - name: app-share
          mountPath: /mnt/app-share
      nodeName: minikube-m02 
      volumes:
      - name: app-share
        persistentVolumeClaim:
          claimName: nfs-claim


$ kubectl apply -f app-2.yaml 
deployment.apps/app-2 created


$ kubectl get deploy,pods -o wide
NAME                    READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS   IMAGES   SELECTOR
deployment.apps/app-1   1/1     1            1           24s     nginx        nginx    app=app-1
deployment.apps/app-2   1/1     1            1           21s     nginx        nginx    app=app-2

NAME                         READY   STATUS    RESTARTS   AGE     NODE           
pod/app-1-7874b8d7b6-p9cb6   1/1     Running   0          23s     minikube       
pod/app-2-fddd84869-fjkrw    1/1     Running   0          21s     minikube-m02   
</code></pre>
<p>To verify that our NFS share works as expected, we can create a file in the <code>app-1</code> and then check that we can see that file in the <code>app-2</code> and on the host:</p>
<p><em>app-1:</em></p>
<pre><code>$ kubectl exec -it app-1-7874b8d7b6-p9cb6 -- bash
root@app-1-7874b8d7b6-p9cb6:/# df -h | grep &quot;app-share&quot;
192.168.49.1:/mnt/nfs_share  9.7G  7.0G  2.2G  77% /mnt/app-share
root@app-1-7874b8d7b6-p9cb6:/# touch /mnt/app-share/app-1 &amp;&amp; echo &quot;Hello from the app-1&quot; &gt; /mnt/app-share/app-1
root@app-1-7874b8d7b6-p9cb6:/# exit
exit
</code></pre>
<p><em>app-2:</em></p>
<pre><code>$ kubectl exec -it app-2-fddd84869-fjkrw -- ls /mnt/app-share
app-1

$ kubectl exec -it app-2-fddd84869-fjkrw -- cat /mnt/app-share/app-1
Hello from the app-1
</code></pre>
<p><em>host:</em></p>
<pre><code>$ ls /mnt/nfs_share/
app-1

$ cat /mnt/nfs_share/app-1 
Hello from the app-1
</code></pre>
