<p>I'm  trying to create <code>PersistentVolume</code> to share directory on <strong>master (not on nodes)</strong> with the pods, for that, I'm using the following .yaml:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/home/myhostuser/shared"
</code></pre>

<p>And I have the following Deployment .yaml where I'm trying to use the shared above as follow:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  selector:
    matchLabels:
      app: my-app
      replicas: 1
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app
        image: my-app-image 
        volumeMounts:
         - mountPath: /shared_host_path
           name: my-volume
        securityContext:
          privileged: true      
        ports:
        - containerPort: 5000
      volumes:
      - name: my-volume
        hostPath: 
        # directory location on host
          path: "/home/myhostuser/shared/"
</code></pre>

<p>When I'm trying to run <code>ls /home/myhostuser/shared</code> on <strong>host</strong> as except I see files but when I run <code>ls /shared_host_path</code> inside the <strong>pod</strong> I not see files.</p>

<p>What I'm doing wrong?</p>

<p>if you want to have the volume on the master, you have to specify this in the persistentVolume specification, like this</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  local:
    path: /home/myhostuser/shared
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - master
</code></pre>

<p>this is how the Kubernetes scheduler understands that this PersistentVolume is tied to a specific node</p>
