Kubernetes on Windows Persistent Volume

7/13/2017

Does windows minikube support a persistent volume with a hostpath? If so what is the syntax?

I tried:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: kbmongo002
  labels:
    type: local
spec:
  storageClassName: mongostorageclass
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/temp/mongo"
    persistentVolumeReclaimPolicy: Retain
---

This passed validation and created the PV and a PVC claimed it, but nothing was written to my expected location of C:\temp\mongo

I also tried:

  hostPath:
    path: "c:/temp/mongo"
    persistentVolumeReclaimPolicy: Retain
---

That resulted in:

Error: Error response from daemon: Invalid bind mount spec 
"c:/temp/mongo:/data/db": invalid mode: /data/db 
Error syncing pod 
-- KenB
kubectl
kubernetes
minikube
windows-10

2 Answers

10/24/2017

I have tried k8s hostpath on windows, it works well. You should use drive letter in pod mount path, see example: https://github.com/andyzhangx/Demo/blob/master/windows/azuredisk/aspnet-pod-azuredisk.yaml#L14

As there is a docker mount path related bug on windows, you need to use drive letter as mount path in pod, see issue: https://github.com/moby/moby/issues/34729

-- andy zhang
Source: StackOverflow

7/18/2017

If you use virtualbox in windows, only the c:/Users is mapped into vm as /c/Users which is kubernetes system can access. It is the feature in Virtualbox.

snapshot

Minikube use VM to simulate the kubernetes VM.

Minikube provides mount feature as well, not so user-friendly for persitency.

You can try choose one of the solutions below

  • use folders under /c/Users for your yaml file
  • map extra folders into virtualbox VM like C:\Users
  • use minikube mount, see host folder mount
-- Larry Cai
Source: StackOverflow