<p>I am testing a connection between a persistent volume and a kubernetes pod by running busybox, but am getting &quot;can't open&quot; &quot;no such file or directory. In order to do further testing, I tried running</p>
<pre><code>echo ls /mntpoint/filename
</code></pre>
<p>This is obviously not the correct command.  I have tried a few other iterations - too many to list here.</p>
<p>I want to run ls of the mountpoint and print to the console.  How do I do this?</p>
<p>EDIT</p>
<p>My code was closest to Rohit's suggestion (below), so I made the following edits, but the code still does not work.  Please help.</p>
<p>Persistent Volume</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: data
  labels:
    type: local
spec:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 1Gi
  hostPath:
    path: &quot;/mnt/data&quot;
  storageClassName: test
</code></pre>
<p>Persistent Volume Claim</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: data
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: test
</code></pre>
<p>Pod</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: persistent-volume
spec:
  containers:
    - name: busybox
      command: ['tail', '-f', '/dev/null']
      image: busybox
      volumeMounts:
        - name: data
          mountPath: &quot;/data&quot;
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: data
</code></pre>
<p>EDIT 2</p>
<p>So, after taking a day off, I came back to my (still running) pod and the command (ls) worked. It works as expected on any directory (e.g. &quot;ls /&quot; or &quot;ls /data&quot;).</p>
<p>My current interpretation is that I did not wait long enough before running the command - although that does not seem to explain it since I had been monitoring with &quot;kubectl describe pod .&quot;  Also I have run the same test several times with short latency between the &quot;apply&quot; and &quot;exec&quot; commands and the behavior has been consistent today.</p>
<p>I am going to continue to keep playing with this, but I think the current problem has been solved.  Than you!</p>

user3877654
<p>Steps you need to follow when dealing with volumes and Kubernetes resources:</p>
<ol>
<li>Create a Persistent volume.</li>
<li>Create a Persistent volume claim and make sure the state is <strong>bound</strong>.</li>
<li>Once the PV and PVC are bounded, try to use the PV from a pod/deployment through PVC.</li>
<li>Check the logs of the pod/deployment. You might see the entry of command execution.</li>
</ol>
<p>Reference: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/</a></p>
<p>Hope this helps, please try to elaborate more and paste the logs of above-mentioned steps.</p>
