<p>I have 3 Kubernetes nodes, one of them is the Master and the others are worker. I deployed Laravel application to the Master Node and created volumes and storage class which points to that folder.
These are my YAML files to create volumes and the persistent volume claim</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
    name: qsinav-pv-www-claim
spec:
    storageClassName: manual
    accessModes:
        - ReadWriteOnce
    resources:
        requests:
            storage: 5Gi
</code></pre>
<p>storage class</p>
<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: manual
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd

apiVersion: v1
kind: PersistentVolume
metadata:
  name: qsinav-pv-www
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  claimRef:
    namespace: default
    name: qsinav-pv-www-claim
  hostPath:
    path: &quot;/var/www/html/Test/qSinav-starter&quot;
</code></pre>
<p>The problem is that the pods in every node try to mount the folder in its parent node.
So as I am running a Web application and I have load balancing between these nodes, if I logged in node one and the next request went to node 2 it redirects me to the login page as I don't have a session there.
So I need to share 1 folder from a master node with all worker nodes.
I don't know what should I do to achieve my goal, so please help me to solve it
Thanks in advance</p>

Muhammad ahmad
<p>Yeah that's expected and is clearly mentioned in the docs for <code>hostPath</code> volume.</p>
<blockquote>
<p>Pods with identical configuration (such as created from a PodTemplate)
may behave differently on different nodes due to different files on
the nodes</p>
</blockquote>
<p>You need to use something like <a href="https://kubernetes.io/docs/concepts/storage/volumes/#nfs" rel="nofollow noreferrer">nfs</a> which can be shared between nodes. You PV definition would end up looking something like this (change IP &amp; path as per your setup):</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: qsinav-pv-www
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  claimRef:
    namespace: default
    name: qsinav-pv-www-claim
  nfs: 
    path: /tmp 
    server: 172.17.0.2
</code></pre>
