<p>I want to share my non-empty local directory with kind cluster.</p>
<p>Based on answer here: <a href="https://stackoverflow.com/questions/62694361/how-to-reference-a-local-volume-in-kind-kubernetes-in-docker">How to reference a local volume in Kind (kubernetes in docker)</a></p>
<p>I tried few variations of the following:</p>
<p>Kind Cluster yaml:</p>
<pre><code>kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraMounts:
  - hostPath: /Users/xyz/documents/k8_automation/data/manual/
    containerPath: /host_manual
  extraPortMappings:
  - containerPort: 30000
    hostPort: 10000
</code></pre>
<p>Pod yaml:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: manual 
spec:
  serviceAccountName: manual-sa
  containers:
  - name: tools 
    image: tools:latest 
    imagePullPolicy: Never
    command:
    - bash
    tty: true
    volumeMounts:
    - mountPath: /home/jenkins/agent/data
      name: data
  volumes:
  - name: data
    hostPath: 
      path: /host_manual
      type: Directory
---
</code></pre>
<p>I see that the directory /home/jenkins/agent/data does exist when the pod gets created. However, the folder is empty.</p>
<p>kinds documentation here: <a href="https://kind.sigs.k8s.io/docs/user/configuration/#extra-mounts" rel="nofollow noreferrer">https://kind.sigs.k8s.io/docs/user/configuration/#extra-mounts</a></p>
<p>It should be the case that whatever is in the local machine at hostpath (/Users/xyz/documents/k8_automation/data/manual/) in extraMounts in the cluster yaml be available to the node at containerPath (/host_manual), which then gets mounted at container volume mounthPath (/home/jenkins/agent/data).</p>
<p>I should add that even if I change the hostPath in the cluster yaml file to a non-existent folder, the empty &quot;data&quot; folder still gets mounted in the container, so I think it's the connection from my local to kind cluster that's the issue.</p>
<ol>
<li>Why am I not getting the contents of /Users/xyz/documents/k8_automation/data/manual/ with it's many files also available at /home/jenkins/agent/data in the container?</li>
<li>How can I fix this?</li>
<li>Any alternatives if there is no fix?</li>
</ol>

<p>Turns out these yaml configuration was just fine.</p>
<p>The reason the directory was not showing up in the container was related with docker settings. And because &quot;kind is a tool for running local Kubernetes clusters using Docker container “nodes”&quot;, it matters.</p>
<p>It seems docker restricts resource sharing and allows only specific directories to be bind mounted into Docker containers by default. Once I added the specific directory I wanted to show up in the container to the list of directories under Preferences -&gt; Resources -&gt; File sharing, it worked!</p>
