-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kubernetes Volumes not correctly mounted with WSL2 #5325
Comments
Any update on this? |
Unfortunately, we don't support hostpath volumes in wsl2. (we don't support them officially with hyper-v either, but there are some potential tricks to make them work). I'll try to find a workaround for you, but it is a tricky subject. |
@simonferquel I'll appreciate if you can provide the workaround for this. |
So the idea here would be to leverage cross distro mounts. You can put things there to share with other distros, and to docker daemon (that is how we handle docker bind mounts under the hood). So, start by creating a mountpoint in there, and mount the directory you want to share with your pods:
/mnt/wsl is actually the mount point for the cross-distro mounts tmpfs So from windows side (not wsl) you can try running: Then you can use hostmounts with paths rewritten with the /run/desktop/mnt/host/wsl prefix in your pods. Please note that this will break if you restart without recreating the bind mount before running docker though. |
@simonferquel Can you point me at some docs regarding recommended method to mount volumes in WSL2 and Docker Desktop? I have all the requisite versions, but there doesn't seem to be good docs on the recommended or preferred method to access files in the Windows environment either via mounts in WSL2 or otherwise. |
To clarify it feels like there needs to be some disambiguation between the wider kubernetes docs and what is available in the WSL2/Docker Desktop install. Some task based docs would be amazing. |
There is no official "mount from a wsl distro" volume support yet (if it becomes a popular demand we will change that, likely with some docker desktop specific volume plugin). |
@simonferquel thanks for the response, it is very possible that I'm misunderstanding some nomenclature. After some teeth nashing I got this working:
How does that differ from what you said wasn't possible? |
Your storage class is local-storage, not hostpath. ;) |
Issues go stale after 90d of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
This should be documented somewhere (other than here I mean). Thanks a lot. |
Definitely agree with @jloic that this needs to be easier to find. @simonferquel 's suggestion worked for me (after I discovered the scrollbar!) with these commands:
Then the relevant parts of my pod configuration:
We already have path translating between host and container so this is a workable step in a solution for us. Making sure the bind-mount is set up before starting the docker daemon will be a nuisance but manageable. It would be useful to know if/when there's a canonical/correct way to do this that automatically sets up the bind as required. |
The challenge we have with hostmount, is that when a Pod is created, we can't know from which distro it comes (as usually PODs, are created trough deployments, statefulsets, daemonsets etc., that do not propagate origin owner identity to child resources). |
That does make for quite a problem. I get confused reconciling host/VM/container paths and I have the complete context 😁 I'll see if we can manage with simple bind mounts like this, if we can script it or otherwise make it as simple as possible it may suffice for development. |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
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
Directory "/volumes" have 777 permissions
Volumes looks like that :
PersistenVolumeClaim are bounds to the volumes
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
Information
Windows Version: 10 build 19037
Docker Desktop Version: 2.1.7.0 (41536) Edge
Kubetctl Version Client : 1.17.0
Server : 1.15.5
helm V3.0.1+g7c22ef9
Docker 19.03.5
Deployment File
Source: charts/supervision/templates/persistent-volumes.yaml
Source: charts/supervision/templates/persistent-volume-claims.yaml
The text was updated successfully, but these errors were encountered: