<p>In my <code>/mnt/</code> I have a number of hard drives mounted (e.g. at <code>/mnt/hdd1/</code>, <code>/mnt/hdd2/</code>). Is there any way to make a K8s Persistent Volume on <code>/mnt</code> that can see the content of the hard drives mounted under <code>/mnt</code>? When I make a Local Persistent Volume on <code>/mnt</code>, the K8s pods see the directories hdd1 and hdd2, but they appear as empty.</p>
<p>The following is what I have tested:</p>
<h3>Undesired solution 1:</h3>
<p>I can make a Local Persistent Volume on <code>/mnt/hdd1</code> and then my K8s pod will be able to see the contents of hdd1 hard drive. But as I mentioned before, I want my pod to see <strong>all</strong> the hard drives and I don't want to make a persistent volume for each hard drive especially when I mount a new hard drive under <code>/mnt</code>.</p>
<h3>Undesired solution 2:</h3>
<p>I can mount a Local Persistent Volume on <code>/mnt/</code> with the K8s option of <code>mountPropagation: HostToContainer</code> in the yaml file for my deployment. In this case my pod will see the content of the hard drive if I <strong>remount</strong> the hard drive. But this is not desired because if the pod restarts,  I need to remount the hard drive again for the pod to see its content! (Only works when hard drive is remounted when the pod is alive)</p>

Ali_MM
<p>I was able to allow the pod to see all hard drives mounted in a directory using hostpath. A PersistentVolume can be defined in hostpath &quot;mode.&quot; My final solution was:</p>
<ol>
<li>Most important part of the solution: <strong>Define a PersistentVolume in hostpath &quot;mode,&quot;</strong> with a nodeAffinity to ensure it will only be mounted on the node with the hard drives:</li>
</ol>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: all-harddrives-pv
spec:
  volumeMode: Filesystem
  storageClassName: all-harddrives-storage
  hostPath:
    path: /mnt      # Where all the hard drives are mounted
    type: Directory
  nodeAffinity:     # Use nodeAffinity to ensure it will only be mounted on the node with harddrives.
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - MyNodeName
</code></pre>
<ol start="2">
<li>Define a PersistentVolumeClaim that is bound to the above PV:</li>
</ol>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: all-harddrives-pvc
spec:
  storageClassName: all-harddrives-storage
</code></pre>
<ol start="3">
<li>Mount it on the Deployment:</li>
</ol>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-deployment
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: my-deployment
    spec:
      containers:
        - name: mycontainername
          image: myimage
          volumeMounts:
            - mountPath: /mnt
              name: all-harddrives-pvc
      nodeSelector:
        kubernetes.io/hostname: MyNodeName
</code></pre>
