Kubernetes hostpath volume with WLS2 does not work

12/14/2019

I have migrated to WSL2 - Windows 10. Since I have the following issue :

Hostpath volume are not mounted into containers. (directory are empty)

The volumes are well created, the desired path is correct. Like

/volumes/my-cluster/services1/www

Directory "/volumes" have 777 permissions

Volumes looks like that :

vol-www 30Mi RWO Retain Bound jeedom/pvc-www hostpath 19m

PersistenVolumeClaim are bounds to the volumes

pvc-www Bound vol-www 30Mi RWO hostpath 19m

In WSL1, at the start of the deployment (or helm charts installation). If Directories does not exists, they are created. Volume are mounted to the containers and work well Conditions : volumes must be mounted in /c/.... (not in /mnt/c/...)

With WSL2, there is no need to mount volume in /c/... docker run -v /volumes/my-cluster/services1/www:/var/html/www my-image work well.

With kubernetes, local directories are not created. directory in container are empty. When creating a files on wsl path, it's not appears in the container, and the other way around doesn't work either.

More, the method who works with WSL1 don't work with WSL2 (mount volume in /c/...)

Thanks

-- Sylvain Goubaud
kubernetes
kubernetes-helm
persistent-volumes
windows-subsystem-for-linux

0 Answers