I am testing a connection between a persistent volume and a kubernetes pod by running busybox, but am getting "can't open" "no such file or directory. In order to do further testing, I tried running
echo ls /mntpoint/filename
This is obviously not the correct command. I have tried a few other iterations - too many to list here.
I want to run ls of the mountpoint and print to the console. How do I do this?
EDIT
My code was closest to Rohit's suggestion (below), so I made the following edits, but the code still does not work. Please help.
Persistent Volume
apiVersion: v1
kind: PersistentVolume
metadata:
name: data
labels:
type: local
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
path: "/mnt/data"
storageClassName: test
Persistent Volume Claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: test
Pod
apiVersion: v1
kind: Pod
metadata:
name: persistent-volume
spec:
containers:
- name: busybox
command: ['tail', '-f', '/dev/null']
image: busybox
volumeMounts:
- name: data
mountPath: "/data"
volumes:
- name: data
persistentVolumeClaim:
claimName: data
EDIT 2
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. "ls /" or "ls /data").
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 "kubectl describe pod <pod>." Also I have run the same test several times with short latency between the "apply" and "exec" commands and the behavior has been consistent today.
I am going to continue to keep playing with this, but I think the current problem has been solved. Than you!
We cannot directly access volume mount on the POD without create a claim. You are missing some steps here.
Once these steps are done you can access the files from your volume in the pod.
Go through the link for detailed information and steps.
Steps you need to follow when dealing with volumes and Kubernetes resources:
Reference: https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/
Hope this helps, please try to elaborate more and paste the logs of above-mentioned steps.