2

When I mount a directory in Minikube and list out the directory, I get the errors below:

ls: cannot access '/mnt/nilla/assets': Bad file descriptor
ls: cannot access '/mnt/nilla/lib': Bad file descriptor
ls: cannot access '/mnt/nilla/priv': Bad file descriptor
ls: cannot access '/mnt/nilla/config': Bad file descriptor
ls: cannot access '/mnt/nilla/README.md': Bad file descriptor
ls: cannot access '/mnt/nilla/mix.exs': Bad file descriptor
ls: cannot access '/mnt/nilla/test': Bad file descriptor
ls: cannot access '/mnt/nilla/testmount': Bad file descriptor
total 0
-????????? ? ? ? ?            ? README.md
d????????? ? ? ? ?            ? assets
d????????? ? ? ? ?            ? config
d????????? ? ? ? ?            ? lib
-????????? ? ? ? ?            ? mix.exs
d????????? ? ? ? ?            ? priv
d????????? ? ? ? ?            ? test
-????????? ? ? ? ?            ? testmount

This is problem because when I mount this directory in my pod, the lsyncd service is copying it to a distribution folder. lsyncd does not know what to do with files that don't have proper descriptors.

I mount the the volume after starting Minikube, like:

nohup minikube mount ${HOME}/Development/nilla/:/mnt/nilla &> /dev/null &

How can I mount a directory and transfer the normal file descriptors that appear when I list the directory on my local computer? These are what they look like:

$ < ls -l nilla/
total 28
drwxr-xr-x 6 joes joes 4096 Apr 10 22:23 assets
drwxr-xr-x 2 joes joes 4096 Apr 10 22:23 config
drwxr-xr-x 4 joes joes 4096 Apr 10 22:23 lib
-rw-r--r-- 1 joes joes 1905 Apr 10 22:23 mix.exs
drwxr-xr-x 4 joes joes 4096 Apr 10 22:23 priv
-rw-r--r-- 1 joes joes  735 Apr 10 22:23 README.md
drwxr-xr-x 4 joes joes 4096 Apr 10 22:23 test
-rw-rw-r-- 1 joes joes    0 May 15 23:08 testmount

Additional notes: I'm using System 76's Pop OS, which is a fork of Ubuntu 20, and my Minikube VM is running Ubuntu 20 on Virtual Box.

Thanks.

JoeS
  • 41
  • 5
  • What's your end goal? The directory contents you list look like some sort of application code; it's really really inconvenient to try to use Kubernetes as a development environment, or to directly inject local code into a Kubernetes pod, and I might try setting up the pod by building a Docker image (maybe inside the minikube VM) and then setting a deployment's `image:` to that. – David Maze May 16 '21 at 11:16
  • @DavidMaze my goal is to get hot reloading working from a container deployed by Kubernetes -- a development environment. But, my plan won't work if the file permissions for the directory contents are not translated inside the Minikube VM. The reason is because I'm watch for changes to those files with `lsyncd`. If `lsyncd` doesn't have timestamps on the files, it won't know that they've been changed. – JoeS May 17 '21 at 19:59
  • @JoeS, how did you mount a directory? In [this way](https://minikube.sigs.k8s.io/docs/handbook/mount/#9p-mounts)? Which [driver](https://minikube.sigs.k8s.io/docs/drivers/) did you use for Minikube? – Mikołaj Głodziak May 18 '21 at 14:10
  • @MikołajGłodziak -- nothing so sophisticated! I was having trouble mounting on startup, so I pass the mount command after startup and redirect the output to nowhere: `nohup minikube mount ${HOME}/Development/nilla/:/mnt/nilla &> /dev/null &`. As for the driver -- I was unware we had so many options. Perhaps I'm using one that's not preferred. I will look that up and update the post, or try switching drivers. Thanks. – JoeS May 19 '21 at 04:27
  • @JoeS, you can also try to mount your directory in other ways. [Here](https://stackoverflow.com/questions/48534980/mount-local-directory-into-pod-in-minikube) is good topic about it. – Mikołaj Głodziak May 19 '21 at 11:59
  • Thanks again, @MikołajGłodziak! – JoeS May 19 '21 at 17:21

3 Answers3

0

@MikołajGłodziak in the comments pointed me in the right direction. The problem was the default driver for Minikube. I changed my minikube start command to specify one of the recommended drivers. As an example:

minikube start --driver=docker --mount-string ${HOME}/project/:/mnt/project

NOTE: You may get errors for trying to start up the same Minikube VM with a different driver. If that's the case, minikube delete will delete your current VM and make a new one the next time you run minikube start.

JoeS
  • 41
  • 5
0

This seems to be an issue with minikube, which is currently being worked on.

See https://github.com/kubernetes/minikube/issues/12301

Current workaround is to use another driver.

s3th
  • 1
0

easy way to do this enter image description here

minikube start --driver=docker --mount-start="${HOME}/project/host" --mount
Willie Cheng
  • 7,679
  • 13
  • 55
  • 68