8000 Support for mounting host volumes on start with docker driver by Asarew · Pull Request #8159 · kubernetes/minikube · GitHub
[go: up one dir, main page]

Skip to content

Support for mounting host volumes on start with docker driver - #8159

Merged
tstromberg merged 7 commits into
kubernetes:masterfrom
Asarew:docker-host-volumes
Sep 1, 2020
Merged

tstromberg merged 7 commits into
kubernetes:masterfrom
Asarew:docker-host-volumes

Conversation

@Asarew
@Asarew Asarew commented May 15, 2020 •
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.


Details

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
Copy Markdown
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
Copy Markdown
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.

Details

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
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@Asarew
Asarew force-pushed the docker-host-volumes branch from 598b6f1 to 1909c4b Compare May 15, 2020 09:45
@Asarew
Asarew commented May 15, 2020
Copy link
Copy Markdown
Contributor Author

I signed it

@RA489
RA489 commented May 15, 2020
Copy link
Copy Markdown

I signed it

/check-cla

@Asarew
Asarew commented May 15, 2020
Copy link
Copy Markdown
Contributor Author

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

@RA489
RA489 commented May 15, 2020
Copy link
Copy Markdown

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
Asarew commented May 15, 2020 •
Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Collaborator

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

@Asarew
Asarew commented May 15, 2020
Copy link
Copy Markdown
Contributor Author

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
afbjorklund commented May 15, 2020 •
Copy link
Copy Markdown
Collaborator

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
medyagh commented May 15, 2020 •
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Asarew commented May 18, 2020 •
Copy link
Copy Markdown
Contributor Author

@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
medyagh commented Jun 9, 2020 •
Copy link
Copy Markdown
Member

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

@tstromberg
Copy link
Copy Markdown
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
Copy Markdown
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
Asarew commented Jul 9, 2020
Copy link
Copy Markdown
Contributor Author

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

@medyagh
medyagh commented Jul 9, 2020
Copy link
Copy Markdown
Member

@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
Comment thread pkg/minikube/config/types.go Resolved
@medyagh
medyagh commented Jul 22, 2020
Copy link
Copy Markdown
Member

@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)

@medyagh medyagh left a comment •
Copy link
Copy Markdown
Member

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
Asarew commented Jul 23, 2020 •
Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor

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
Copy Markdown

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

Details
+--------------------------------+-----------+--------------------+
|              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

Details
+--------------------------------+-----------+--------------------+
|              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
Asarew commented Jul 31, 2020 •
Copy link
Copy Markdown
Contributor Author

@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
Asarew commented Aug 25, 2020
Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor

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

@Asarew
Asarew commented Sep 2, 2020
Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

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

@Asarew
Asarew commented Sep 3, 2020
Copy link
Copy Markdown
Contributor Author

Warning added in: #9172 👍

@zamazan4ik
Copy link
Copy Markdown

@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/cobra@v1.0.0/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0x2cdeb40, 0x0, 0x1, 0xc0005ede80)
        /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/cobra@v1.0.0/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
Asarew commented Oct 7, 2020
Copy link
Copy Markdown
Contributor Author

@zamazan4ik you should run $ minikube delete

@Alig1493
Alig1493 commented Dec 30, 2022 •
Copy link
Copy Markdown

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
Asarew commented Jan 3, 2023 •
Copy link
Copy Markdown
Contributor Author

@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
Alig1493 commented Jan 3, 2023
Copy link
Copy Markdown

@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
t1bb4r commented Jun 11, 2023
Copy link
Copy Markdown

@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
0