I need to mount a local directory from my C: drive to my local kubernetes pod. Every time I try it tells me the path is incorrect. What is the solution for this?
apiVersion: v1
kind: PersistentVolume
metadata:
name: dads-files-pv
spec:
capacity:
storage: 10Mi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: hostpath
local:
path: /dads-files/test
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- docker-desktop # must be the name of your node (kubectl get nodes)
if you are using the minikube locally you have to map directloy
minikube mount <source directory>:<target directory>
and
minikube mount $HOME:/host
read more at : https://minikube.sigs.k8s.io/docs/handbook/mount/
I think the definition of your PersistentVolume is not correct.
You should use storageClass manual
to use a local folder as PersistentVolume. An example can be found here
apiVersion: v1
kind: PersistentVolume
metadata:
name: dads-files-pv
spec:
capacity:
storage: 10Mi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: manual
hostPath:
path: /dads-files/test
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- docker-desktop # must be the name of your node (kubectl get nodes)