How to mount a volume from Kubernetes on a Windows host to a Linux pod

1.3k Views Asked by At

I am trying to mount a volume within a Kubernetes pod (running linux) to a host folder on Windows 10. The pod starts up without issue, however, the data in the volumes aren't being reflected within the Pod and data set in the Pod isn't being reflected on the Windows host.

Here is my persistent volume:

    kind: PersistentVolume 
    apiVersion: v1
    metadata:
      name: "elastic-search-persistence"
      labels:
        volume: persistence
    spec:
      storageClassName: hostpath
      capacity:
        storage: 5Gi
      accessmodes:
        - ReadWriteMany
      hostPath:
        path: /c/temp/es

Here is my persistent claim:

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: "elastic-search-persistence-claim"
    spec:
      storageClassName: hostpath
      volumeName: "elastic-search-persistence"
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 5Gi

And here is my Pod using the above persistent volumes...

    apiVersion: v1
    kind: Pod
    metadata:
      name: windows-volume-demo
    spec:
      containers:
      - name: windows-volume-demo
        image: busybox
        command: [ "sh", "-c", "sleep 1h" ]
        volumeMounts:
          - name: windows-volume-data-storage
            mountPath: /data/demo
        securityContext:
          allowPrivilegeEscalation: true
      volumes:
        - name: windows-volume-data-storage
          persistentVolumeClaim:
            claimName: elastic-search-persistence-claim

I can start everything fine, however, when I create a file in my C:\temp\es folder on my Windows host, that file doesn't show inside the /data/demo folder in the Pod. And the reverse is also true. When I exec into the Pod and create a file in the /data/demo folder, it doesn't show in the C:\temp\es folder on the Windows host.

The folder/file privileges are wide open for the C:\temp folder and the C:\temp\es folder. I also tried exec-ing into the Pod and changing the write privs for the /data/demo folder to wide open -- all with no success.

This configuration works as expected on a Mac host (changing the volume paths for the host to a Mac folder). I suspect it is a privilege/permissions issue for Windows, but I am at a loss as to how to find/fix it.

Any help would be greatly appreciated.

0

There are 0 best solutions below