I am running Docker Desktop 4.10 on Windows 10, with K8s enabled. I have the following k8s resources deployed through a helm chart, using Helm 3.12:
apiVersion: v1
kind: PersistentVolume
metadata:
name: fab-rabbitmq
labels:
type: mydata
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
storageClassName: hostpath
hostPath:
path: /c/data
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc1
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 2Gi
storageClassName: hostpath
selector:
matchLabels:
type: "mydata"
---
apiVersion: v1
kind: Pod
metadata:
name: pod1
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: "/mydata"
name: vol1
volumes:
- name: vol1
persistentVolumeClaim:
claimName: pvc1
After deploying the chart, the pod runs correctly, the PVC is bound to the PV. I also set Windows security permissions to Everyone-full control on C:\data.
However, when I access the pod and try to list the files in the folder, I get the following error:
kubectl exec -it pod1 bash
# ls -la mydata
ls: reading directory 'mydata': Operation not permitted
I can't seem to find a way to really have access to the mounted folder.
When I try to run a simple container using docker run -v /c/data:/mydata nginx and access /mydata, it works.
Any ideas what I am doing wrong?
I found the explanation here and here. When running in Minikube, the "host path" is not actually the path on the physical host but rather a path inside the Minikube node. That's because Minikube IS actually the host of all pods (hence their node). So basically, the steps to do this correctly are:
minimuke start --mount --mount-string=C:\myfolder:/folder/in/minikubehostPath.path: /folder/in/minikube:/folder/in/pod