-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Support mounting host directories into pods #2
Comments
One possibility here might be to support an NFS-based persistent volume claim from the guest to the host: http://kubernetes.io/docs/user-guide/persistent-volumes/ |
On Mon, May 16, 2016 at 05:31:18PM -0700, dlorenc wrote:
NFS persistent volume claim? What? Why? Why not HostPath, to use a local directory, and that's all regarding the volume? |
Of course, HostPath will work right now, but it won't mount things into the VM from the outside host. For that to work we might need to do dynamic mounting/provisioning from the laptop into the VM. |
On Mon, May 16, 2016 at 05:42:00PM -0700, dlorenc wrote:
Oh, I see what you mean now. But I'm not sure, as @vishh said in the original NFS is another option, but I'm not sure how that would work. A host dir in the |
Also, if docker is used, it can mount from host directly on mac/windows with docker "native" beta. One option is to use that. Another is to do the same/similar trick that docker is using (probably the one @vishh said and the one I said in my previous post) |
If we can have kubelet take in a configurable |
this feature is super important for us, is there any way to let me add a shared folder before this come out ? |
Hey, on a Mac using Virtualbox, the /Users/ directory is automatically mapped into the VM (also under /Users). You could then use a HostPath volume of "/Users/$USER/$DIR". Does that help? |
@dlorenc thx, I add |
The permission issues that @Ehekatl mentions are quite a blocker. With a PersistentVolume mounted to a pod with a https://hub.docker.com/_/postgres/ container I get:
When postgres tries to create data there it fails with
I've tested with both virtualbox and xhyve minikube, on Mac. |
@solsson: maybe it's an option to add permission to the volume API in kubernetes. I'm doing that for others volumes: kubernetes/kubernetes#28733 and kubernetes/kubernetes#28936 |
I noticed that kubernetes/kubernetes#28733 is merged now. Interesting. Before Docker for Mac, with Docker Toolbox and boot2docker, I had this kind if issue often with plain docker containers. Hence I'm not so sure the issue is with Kubernetes. Maybe it's inherent with docker + non-privileged user + virtual machine mount. If I use /tmp/somevolume as This leads me to believe that the problem is with minikube. After all hostPath works fine on for example GKE. Maybe it's with how minikube mounts the shared folder? |
This boot2docker issue describes the problem pretty accurately. I think I found a workaround for virtualbox. After
The first three options are from the default mount. Probably only one of the added options are needed. With postgres howerver the next issue is:
which I think confims my suspicion that docker and vm shared folders is not a good fit. |
In conclusion, an added mount option (see above) might improve minikube. But until native docker is supported, including Docker for Mac, I think that to stay sane one should realize that some services demand a lot from the file system and hostPath should really be the linux host's folder. With So to access this data directly I'd have to share it from the VM to my physical host. |
On Mon, Jul 18, 2016 at 10:49:17AM -0700, solsson wrote:
Why it is not a good fit? Why do those errors happen? |
These are the steps I look to get hostPath working on OSX with NFS. Using xhyve, but I imagine this works for other VMs. # install bits
brew install docker kubectl docker-machine-driver-xhyve
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
# setup bits
sudo echo "/Users -network 192.168.64.0 -mask 255.255.255.0 -alldirs -maproot=root:wheel" > /etc/exports
sudo nfsd restart
minikube start --vm-driver=xhyve
minikube ssh -- sudo /usr/local/etc/init.d/nfs-client start
minikube ssh -- sudo mkdir /Users
minikube ssh -- sudo mount 192.168.64.1:/Users /Users -o rw,async,noatime,rsize=32768,wsize=32768,proto=tcp
eval $(minikube docker-env) |
Because vboxsf mounts are quite limited as file system. I did not investigate the postgres issue further. For vbox minikube based on your NFS instructions (with
Much better than shared folder, as uid + gid + mod is preserved. |
The existing vboxfs system isn't great. We should figure out whether to use NFS or 9p, and make this work for all drivers. |
kernel: add 9P support
We should document how to setup NFS in the meantime. |
Latest minikube 0.15 iso image doesn't support vboxsf anymore, it seems. I also tried NFS to no avail. Anyway, IMHO NFS is /not/ better than vboxsf. I usually have some python code running in gunicorn with the --reload option, which uses inotify. NFS doesn't support inotify, so it will be probably have to revert to polling, which is slower and more resource consuming. Even NFS I couldn't get to work:
How can you release a minikube version without any working option for sharing folders between guest and host?... :( |
Restore "containerd: upgrade io.containerd.runtime.v1.linux to io.containerd.runc.v2 (suppot cgroup v2)" #2
Having the ability to mount local directories to pods will improve the developer experience a lot.
Given that most hypervisors can already support mapping host directories, adding this feature should be straightforward.
The text was updated successfully, but these errors were encountered: