Skip to content
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 for mounting host volumes on start with docker driver #8159

Merged
merged 7 commits into from
Sep 1, 2020

Conversation

Asarew
Copy link
Contributor

@Asarew Asarew commented May 15, 2020

To use this PR run the minikube start with the --mount option like so:

Description:

$ minikube start --mount

this will automatically mount your home directory in the minikube host at path /minikube-host

Or specify a mount path:

$ minikube start --mount --mount-string "/dir/to/share:/dir/where/to/mount"

Usage:

$ mkdir testdir
$ echo "hello" > testdir/world.txt
$ minikube start --mount --mount-string $(pwd)/testdir:/dir/testdir --driver=docker
😄  minikube v1.12.0-beta.0 on Linuxmint 19.2
✨  Using the docker driver based on user configuration
👍  Starting control plane node minikube in cluster minikube
🔥  Creating docker container (CPUs=8, Memory=10000MB) ...
🐳  Preparing Kubernetes v1.18.3 on Docker 19.03.2 ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: default-storageclass, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube"
$ minikube ssh
docker@minikube:~$ cat /dir/testdir/world.txt
hello
docker@minikube:~$ echo "goodbye" > /dir/testdir/sky.txt
docker@minikube:~$ exit
$ cat testdir/sky.txt
goodbye

fixes: #7604

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 15, 2020
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label May 15, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @Asarew!

It looks like this is your first PR to kubernetes/minikube 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/minikube has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 15, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @Asarew. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 15, 2020
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@Asarew
Copy link
Contributor Author

Asarew commented May 15, 2020

I signed it

@RA489
Copy link

RA489 commented May 15, 2020

I signed it

/check-cla

@Asarew
Copy link
Contributor Author

Asarew commented May 15, 2020

Don't know why but the cla-bot doesn't re-check my cla @RA489 any idea on what i should do next?

@RA489
Copy link

RA489 commented May 15, 2020

Don't know why but the cla-bot doesn't re-check my cla @RA489 any idea on what i should do next?

do you mind verifying that the e-mail address you have on GitHub matches the one you signed the CLA with?

@Asarew
Copy link
Contributor Author

Asarew commented May 15, 2020

Yeah, i double checked that both commits have the correct author email address and that it's the same as my github email and the one i used to sign the CLA.

@Asarew Asarew changed the title WIP: support for mounting host volumes on start Support for mounting host volumes on start with docker driver May 15, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 15, 2020
@afbjorklund
Copy link
Collaborator

Same comment as with #8136, does this have to be docker-specific ?

@Asarew
Copy link
Contributor Author

Asarew commented May 15, 2020

Currently this is a docker specific things as and podman are the only drivers that would support this feature.
I do believe that the intended behaviour is similar like --mount-string but that would spawn the mount deamon, and i don't think we should overwrite that.

or are you talking about making the flag name not docker specific; something like --volume-mount.

@afbjorklund
Copy link
Collaborator

afbjorklund commented May 15, 2020

Currently this is a docker specific things as and podman are the only drivers that would support this feature.

We can copy it from docker-volume to podman-volume, just like with did with docker-env and podman-env. Just that it gets a bit boring after a while, with all the duplication and copy/paste.

Since 90% of the implementation is exactly the same, except some minor details like "sudo". And ultimately it would also be nice to align this with extra disk images for the hypervisors...

or are you talking about making the flag name not docker specific; something like --volume-mount.

Yeah, but you can go ahead with this feature without it. We can copy/paste it, after this PR.

I don't think we will make it generic anyway, so it is "both" rather than "any" - see #7957

@medyagh
Copy link
Member

medyagh commented May 15, 2020

I agree with @afbjorklund , we should try to make this not docker secific. on these both PRs

I wonder if we should the existing "-mount-string" option on start? instead of making it docker-specific flag?

@afbjorklund
Copy link
Collaborator

we should try to make this not docker secific. on these both PRs

then again it already is, so this doesn't really make it much worse

I mean since we already have "docker-env" and "docker-opt" :

      --docker-env=[]: Environment variables to pass to the Docker daemon. (format: key=value)
      --docker-opt=[]: Specify arbitrary flags to pass to the Docker daemon. (format: key=value)

It's easy enough to copy/paste these into podman-env/podman-opt.

Even with a new "docker-vol" (or whatever) flag added here as well.

@Asarew
Copy link
Contributor Author

Asarew commented May 18, 2020

@afbjorklund @RA489 I can add the --podman-volume flag. do you want this in this PR or should i create a new one?

ps: I still need some help with my CLA

@medyagh
Copy link
Member

medyagh commented Jun 9, 2020

@Asarew do you mind putting the PR description eample of using this so I could test it

@tstromberg
Copy link
Contributor

I don't love that this effectively duplicates --mount-string with a driver-specific flag, but I see there are some options as for the type of mount it supports.

@tstromberg
Copy link
Contributor

I like this PR. Can you make this use --mount-string instead of adding a new string? You could preserve the parsing & handling logic.

@Asarew
Copy link
Contributor Author

Asarew commented Jul 9, 2020

@medyagh Figured out what i did wrong, CLA is signed!

@medyagh
Copy link
Member

medyagh commented Jul 9, 2020

@medyagh Figured out what i did wrong, CLA is signed!

thank you :) I will re-review this PR tomorrow theoverall the PR looks good small minior things might need to change

@medyagh medyagh changed the title needs-cla:Support for mounting host volumes on start with docker driver Support for mounting host volumes on start with docker driver Jul 22, 2020
pkg/minikube/config/types.go Outdated Show resolved Hide resolved
pkg/minikube/registry/drvs/docker/docker.go Outdated Show resolved Hide resolved
@medyagh
Copy link
Member

medyagh commented Jul 22, 2020

@Asarew do you mind addressing the review comments and also update the PR descrtiption with the output of example of using it with vadlidaitons ? (mount a folder and then ls it inside minikube)

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Asarew I tried this manually and it didnt seem to work

since the output of ls /dir/med1/ was empty but I was expecting a file to be there

medya@~/workspace/minikube (mount_do1) $ ./out/minikube start --driver=docker --mount --mount-string "/Users/medya/workspace/minikube/med:/dir/med1"
😄  minikube v1.12.1 on Darwin 10.15.6
✨  Using the docker driver based on user configuration
👍  Starting control plane node minikube in cluster minikube
🔥  Creating docker container (CPUs=2, Memory=3892MB) ...
🐳  Preparing Kubernetes v1.18.3 on Docker 19.03.2 ...
🔎  Verifying Kubernetes components...
📁  Creating mount /Users/medya/workspace/minikube/med:/dir/med1 ...
🌟  Enabled addons: default-storageclass, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube"
medya@~/workspace/minikube (mount_do1) $ ./out/minikube ssh
docker@minikube:~$ ls /dir/med1/
docker@minikube:~$ exit
logout


medya@~/workspace/minikube (mount_do1) $ ls /Users/medya/workspace/minikube/med
med.txt

…d added same host mounted volumes logic for the Podman driver
@Asarew
Copy link
Contributor Author

Asarew commented Jul 23, 2020

@medyagh I resolved all your comments, but the build is failing on some windows hyperv test. I don't see how this PR can impact those tests as there are clear checks that wouldn't allow any of these changes to run in the hyperv test. Would you be able to rerun the test, just to ensure that not something else is going on?

You were correct that it didn't seem to work. I fixed the issue, tested, and added the output to the PR description.

@Asarew Asarew requested a review from medyagh July 23, 2020 10:31
@sharifelgamal
Copy link
Collaborator

The Hyper-V test failures are not related to this PR at all. This is looking good.

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 29, 2020
@minikube-pr-bot
Copy link

kvm2 Driver
Times for minikube: [64.70219117000002 62.787032046 64.764618787]
Average time for minikube: 64.08461400099999

Times for Minikube (PR 8159): [61.08094720900001 62.28869980199998 64.22172085199999]
Average time for Minikube (PR 8159): 62.53045595433334

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 8159) |
+--------------------------------+-----------+--------------------+
| * minikube v1.12.1 on Debian   |  0.056262 |           0.057735 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.018509 |           0.019669 |
| on existing profile            |           |                    |
| * Starting control plane node  |  0.003094 |           0.003029 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 41.174322 |          40.722506 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.3 | 21.332522 |          20.086174 |
| on Docker 19.03.12 ...         |           |                    |
| * Verifying Kubernetes         |  1.337521 |           1.279009 |
| components...                  |           |                    |
| * Enabled addons:              |  0.089751 |           0.290517 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.069124 |           0.066916 |
| configured to use "minikube"   |           |                    |
|                                |  0.003507 |           0.004902 |
+--------------------------------+-----------+--------------------+

docker Driver
Times for minikube: [26.397569994 25.320311832999998 26.027249107]
Average time for minikube: 25.915043644666667

Times for Minikube (PR 8159): [25.613505958999998 27.683200873999997 26.28687423]
Average time for Minikube (PR 8159): 26.52786035433333

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 8159) |
+--------------------------------+-----------+--------------------+
| * minikube v1.12.1 on Debian   |  0.078930 |           0.077057 |
|                           9.11 |           |                    |
| * Using the docker driver      |  0.097760 |           0.097654 |
| based on existing profile      |           |                    |
| * Starting control plane node  |  0.055774 |           0.055361 |
| minikube in cluster minikube   |           |                    |
| * Creating docker container    |  8.242806 |           8.189097 |
| (CPUs=2, Memory=3700MB) ...    |           |                    |
| * Preparing Kubernetes v1.18.3 | 16.533487 |          17.173572 |
| on Docker 19.03.2 ...          |           |                    |
| * Verifying Kubernetes         |  0.835869 |           0.831316 |
| components...                  |           |                    |
| * Enabled addons:              |  0.002610 |           0.035954 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.064641 |           0.062982 |
| configured to use "minikube"   |           |                    |
|                                |  0.003166 |           0.004868 |
+--------------------------------+-----------+--------------------+

@Asarew
Copy link
Contributor Author

Asarew commented Jul 31, 2020

@medyagh i was just thinking that i should add a warning when you try to change the mount-string on minikube start after the cluster has already been created. Because docker doesn't allow changing of volumes after the container has been created.
Also i should probably disallow the minikube mount command with a message to use --mount-string on creation as it (currently) doesn't work anyway. I think it will be easier to understand for the end-user what is going on and what should be done.

@Asarew
Copy link
Contributor Author

Asarew commented Aug 25, 2020

@medyagh @sharifelgamal @tstromberg is there anything i can do to get this merged asap?

@tstromberg tstromberg merged commit 8a26881 into kubernetes:master Sep 1, 2020
@tstromberg
Copy link
Contributor

Done. Thank you for your patience! I like your idea about adding a warning if a mount is attempted after creation.

@Asarew
Copy link
Contributor Author

Asarew commented Sep 2, 2020

Thanks! I'll create a new PR in a couple of days for the warning(s). Do you know hen the next release is scheduled? So i can attempt to get it done before then.

@tstromberg
Copy link
Contributor

v1.13 will likely ship by tomorrow, with a v1.13.1 likely next Thursday to catch Kubernetes v1.19.1.

@Asarew
Copy link
Contributor Author

Asarew commented Sep 3, 2020

Warning added in: #9172 👍

@zamazan4ik
Copy link

@Asarew Thanks for so nice addition. I am trying to test it a little bit and got the following error:

minikube start --driver=docker --mount-string "/media/storage/wallpaper_service/filtered_images:/data/wallpapers" --mount                                       
😄  minikube v1.13.1 on Fedora 32
✨  Using the docker driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🏃  Updating the running docker "minikube" container ...
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
k8s.io/minikube/cmd/minikube/cmd.runStart(0x2cd9c80, 0xc000613240, 0x0, 0x4)
        /app/cmd/minikube/cmd/start.go:216 +0x15d3
github.com/spf13/cobra.(*Command).execute(0x2cd9c80, 0xc000613200, 0x4, 0x4, 0x2cd9c80, 0xc000613200)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0x2cdeb40, 0x0, 0x1, 0xc0005ede80)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:887
k8s.io/minikube/cmd/minikube/cmd.Execute()
        /app/cmd/minikube/cmd/root.go:113 +0x929
main.main()
        /app/cmd/minikube/main.go:71 +0x11f

Any ideas?

@Asarew
Copy link
Contributor Author

Asarew commented Oct 7, 2020

@zamazan4ik you should run $ minikube delete

@Alig1493
Copy link

Alig1493 commented Dec 30, 2022

minikube start --mount --mount-string $(pwd)/data/db:/data/db --driver=docker
Doesn't seem to work
minikube ssh has no contents of the mounted folder
image
whereas on the host, the folder has a file:
image

Using a linux machine with docker driver.

@Asarew
Copy link
Contributor Author

Asarew commented Jan 3, 2023

@Alig1493 not 100% sure anymore on this as I'm not using minikube anymore, but if i remember correctly you also have to pass the --mount flag.

@Alig1493
Copy link

Alig1493 commented Jan 3, 2023

@Alig1493 not 100% sure anymore on this as I'm not using minikube anymore, but if i remember correctly you also have to pass the --mount flag.

Hey @Asarew thanks for responding regardless. As you can see in my comment I did pass the mount flag along with the mount-string args.

@t1bb4r
Copy link

t1bb4r commented Jun 11, 2023

@Alig1493 see #10490

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request: mount host volumes into docker driver via docker -v