<p>I'd like to access and edit files in my Kubernetes <strong>PersistentVolume</strong> on my local computer (macOS), but I cannot understand where to find those files!</p>

<p>I'm pointing my <code>hostPath</code> to <code>/tmp/wordpress-volume</code> but I cannot find it anywhere. What is the hidden secret I'm missing</p>

<p>I'm using the following configuration on a <strong>docker-for-desktop</strong> cluster <code>Version 2.0.0.2 (30215)</code>.</p>

<h3>PersistentVolume</h3>

<pre><code>kind: PersistentVolume
metadata:
  name: wordpress-volume
spec:
  # ...
  hostPath:
    path: /tmp/wordpress-volume
</code></pre>

<h3>PersistentVolumeClaim</h3>

<pre><code>kind: PersistentVolumeClaim
metadata:
  name: wordpress-volume-claim
# ...
</code></pre>

<h3>Deployment</h3>

<pre><code>kind: Deployment
metadata:
  name: wordpress
# ...
spec:
  containers:
  - image: wordpress:4.8-apache
    # ...
    volumeMounts:
    - name: wordpress-volume
      mountPath: /var/www/html
  volumes:
  - name: wordpress-volume
    persistentVolumeClaim:
      claimName: wordpress-volume-claim
</code></pre>

a.barbieri
<p>Thanks to @aman-tuladhar and some hours lost on the internet I've found out that you just need to make sure <code>storageClassName</code> is set for you <strong>PersistentVolume</strong> and <strong>PersistentVolumeClaim</strong>. </p>

<p>As per <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#dynamic" rel="noreferrer">documentation</a> if you want to avoid that <strong>Kubernetes</strong> dynamically generetes <strong>PersistentVolumes</strong> without considering the one you statically declared, you can just set a empty string <code>" "</code>.</p>

<p>In my case I've set <code>storageClassName: manual</code>.</p>

<h3>PersistentVolume</h3>

<pre><code>kind: PersistentVolume
metadata:
  name: wordpress-volume
spec:
  # ...
  storageClassName: manual
  hostPath:
    path: /tmp/wordpress-volume
</code></pre>

<h3>PersistentVolumeClaim</h3>

<pre><code>kind: PersistentVolumeClaim
metadata:
  name: wordpress-volume-claim
spec:
  storageClassName: manual
  # ...
</code></pre>

<p>This works out of the box with <code>docker-for-desktop</code> cluster (as long as <code>mountPath</code> is set to a absolute path).</p>

<p>References:</p>

<ul>
<li><a href="https://medium.com/@snowmiser/kubernetes-binding-persistentvolumes-and-persistentvolumeclaims-33323b907722" rel="noreferrer">Kubernetes: Binding PersistentVolumes and PersistentVolumeClaims</a></li>
<li><a href="https://medium.com/@xcoulon/storing-data-into-persistent-volumes-on-kubernetes-fb155da16666" rel="noreferrer">Storing data into Persistent Volumes on Kubernetes</a></li>
</ul>
