Skip to content

Conversation

bugwz
Copy link

@bugwz bugwz commented Jul 11, 2025

When using minikube start, we can pass in multiple paths that we want to mount inside the container through the mount-string parameter, for example:

minikube start --mount --mount-string="/data01:/data01;/data02:/data02:Z,rshared"

Copy link

linux-foundation-easycla bot commented Jul 11, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bugwz
Once this PR has been reviewed and has the lgtm label, please assign comradeprogrammer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Welcome @bugwz!

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 Jul 11, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @bugwz. 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-sigs/prow repository.

@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 11, 2025
@medyagh
Copy link
Member

medyagh commented Jul 11, 2025

/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 11, 2025
@medyagh
Copy link
Member

medyagh commented Jul 11, 2025

@bugwz can you plz share Before/After this PR output of minikube?

@minikube-pr-bot

This comment has been minimized.

@bugwz
Copy link
Author

bugwz commented Jul 12, 2025

@medyagh Below is the comparison information, please take a look~

Before:

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]# ./out/minikube version
minikube version: v1.36.0
commit: 78989b99c29903d39ba5a8f2a0fef52d8b2c4497

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]# ./out/minikube start --help
...
    --mount-string='/home/bugwz:/minikube-host':
	The argument to pass the minikube mount command on start.
...

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]$ ./out/minikube start --driver="podman" --mount --mount-string="/data01:/data01"
😄  minikube v1.36.0 on Centos 8.5.2111 (amd64)
✨  Using the docker driver based on user configuration

💣  Exiting due to PROVIDER_DOCKER_VERSION_EXIT_1: "docker version --format <no value>-<no value>:<no value>" exit status 1: Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
time="2025-07-12T12:19:12+08:00" level=error msg="XDG_RUNTIME_DIR directory \"/run/user/0\" is not owned by the current user"
📘  Documentation: https://minikube.sigs.k8s.io/docs/drivers/docker/

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]$ ./out/minikube start --driver="podman" --mount --mount-string="/data01:/data01"
😄  minikube v1.36.0 on Centos 8.5.2111 (amd64)
❗  The minimum required version for podman is "4.9.0". your version is "3.3.1". minikube might not work. use at your own risk. To install latest version please see https://podman.io/getting-started/installation.html
✨  Using the podman driver based on user configuration

🧯  The requested memory allocation of 3072MiB does not leave room for system overhead (total system memory: 3625MiB). You may face stability issues.
💡  Suggestion: Start minikube with less memory allocated: 'minikube start --memory=3072mb'

📌  Using Podman driver with root privileges
👍  Starting "minikube" primary control-plane node in "minikube" cluster
🚜  Pulling base image v0.0.47 ...
💾  Downloading Kubernetes v1.33.2 preload ...
    > preloaded-images-k8s-v18-v1...:  348.11 MiB / 348.11 MiB  100.00% 10.32 M
    > gcr.io/k8s-minikube/kicbase...:  502.26 MiB / 502.26 MiB  100.00% 6.70 Mi
E0712 12:20:35.359832   15917 cache.go:225] Error downloading kic artifacts:  not yet implemented, see issue #8426
🔥  Creating podman container (CPUs=2, Memory=3072MB) ...
🐳  Preparing Kubernetes v1.33.2 on Docker 28.1.1 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]$ sudo podman inspect minikube
[
    {
        "Id": "db2b5308a1f00f4fa9bd5192286f320a0fe4ae8ca636a1a29d386505599a5d7c",
        "Created": "2025-07-12T12:21:45.17550111+08:00",
        "Path": "/usr/local/bin/entrypoint",
        "Args": [
            "/sbin/init"
...
        "Mounts": [
            {
                "Type": "volume",
                "Name": "minikube",
                "Source": "/var/lib/containers/storage/volumes/minikube/_data",
                "Destination": "/var",
                "Driver": "local",
                "Mode": "",
                "Options": [
                    "exec",
                    "nosuid",
                    "nodev",
                    "rbind"
                ],
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/lib/modules",
                "Destination": "/lib/modules",
                "Driver": "",
                "Mode": "",
                "Options": [
                    "rbind"
                ],
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/data01",
                "Destination": "/data01",
                "Driver": "",
                "Mode": "",
                "Options": [
                    "rbind"
                ],
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
...

After:

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]$ ./out/minikube version
minikube version: v1.36.0
commit: 14c679030368174bde9cbd24753f8c141c6e6da0

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]# ./out/minikube start --help
...
    --mount-string='/home/bugwz:/minikube-host':
	The argument to pass the minikube mount command on start, in a semicolon-separated format.
...

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]$ ./out/minikube start --driver="podman" --mount --mount-string="/data01:/data01;/data02:/data02:Z,rshared"
😄  minikube v1.36.0 on Centos 8.5.2111 (amd64)
❗  The minimum required version for podman is "4.9.0". your version is "3.3.1". minikube might not work. use at your own risk. To install latest version please see https://podman.io/getting-started/installation.html
✨  Using the podman driver based on user configuration

🧯  The requested memory allocation of 3072MiB does not leave room for system overhead (total system memory: 3625MiB). You may face stability issues.
💡  Suggestion: Start minikube with less memory allocated: 'minikube start --memory=3072mb'

📌  Using Podman driver with root privileges
👍  Starting "minikube" primary control-plane node in "minikube" cluster
🚜  Pulling base image v0.0.47 ...
E0712 12:30:33.731925   33550 cache.go:225] Error downloading kic artifacts:  not yet implemented, see issue #8426
🔥  Creating podman container (CPUs=2, Memory=3072MB) ...
🐳  Preparing Kubernetes v1.33.2 on Docker 28.1.1 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

[bugwz@iZj6cibr8kn3thfefwcyg3Z minikube]$ sudo podman inspect minikube
[
    {
        "Id": "7cea00a807474ac6a111bc91ab33c9a857ca17831c1ba4df0521221bdca384b9",
        "Created": "2025-07-12T12:30:43.641329142+08:00",
        "Path": "/usr/local/bin/entrypoint",
        "Args": [
            "/sbin/init"
        ],
...
        "Mounts": [
            {
                "Type": "volume",
                "Name": "minikube",
                "Source": "/var/lib/containers/storage/volumes/minikube/_data",
                "Destination": "/var",
                "Driver": "local",
                "Mode": "",
                "Options": [
                    "exec",
                    "nosuid",
                    "nodev",
                    "rbind"
                ],
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/lib/modules",
                "Destination": "/lib/modules",
                "Driver": "",
                "Mode": "",
                "Options": [
                    "rbind"
                ],
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/data01",
                "Destination": "/data01",
                "Driver": "",
                "Mode": "",
                "Options": [
                    "rbind"
                ],
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/data02",
                "Destination": "/data02",
                "Driver": "",
                "Mode": "",
                "Options": [
                    "rbind"
                ],
                "RW": true,
                "Propagation": "rshared"
            }
        ],
...

@medyagh
Copy link
Member

medyagh commented Jul 14, 2025

thank you @bugwz can you plz fix the lint issue ?
u can run "make lint" or look at output of https://github.com/kubernetes/minikube/actions/runs/16223086483/job/45836007332?pr=21056

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.

please see comments and also fix lint issues (make lint)

Name: "relative container path",
MountString: "/foo/bar:baz/bat:private",
ExpectErr: true,
Name: "relative container path",
Copy link
Member

Choose a reason for hiding this comment

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

please add more unit test cases and include some test cases with semi colomon

@@ -173,7 +173,7 @@ func initMinikubeFlags() {
startCmd.Flags().Bool(embedCerts, false, "if true, will embed the certs in kubeconfig.")
startCmd.Flags().StringP(containerRuntime, "c", constants.DefaultContainerRuntime, fmt.Sprintf("The container runtime to be used. Valid options: %s (default: auto)", strings.Join(cruntime.ValidRuntimes(), ", ")))
startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube.")
startCmd.Flags().String(mountString, constants.DefaultMountDir+":/minikube-host", "The argument to pass the minikube mount command on start.")
startCmd.Flags().String(mountString, constants.DefaultMountDir+":/minikube-host", "The argument to pass the minikube mount command on start, in a semicolon-separated format.")
Copy link
Member

Choose a reason for hiding this comment

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

can add an example here for clarity

@bugwz
Copy link
Author

bugwz commented Jul 14, 2025

@medyagh Thank you for the suggestion, it has been updated.

@bugwz bugwz requested a review from medyagh July 14, 2025 15:25
@minikube-pr-bot

This comment has been minimized.

@medyagh
Copy link
Member

medyagh commented Jul 16, 2025

/retest-this-please

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.

@bugwz does this mean multi-mount is only available for when users "starts" minikube?

how about if the user uses "minikube mount" command ?

I feel like this is a super useful feature and we should add some documents about it in our website maybe in tutorials

https://minikube.sigs.k8s.io/docs/handbook/mount/
https://minikube.sigs.k8s.io/docs/commands/mount/

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.

I tried manually, the "mount command" also needs to be updated so it can support multiple mount folders, would you plz add that feature there as well ?

$ minikube mount ~/.asdf/:/tmp1/;~/.vscode/:/tmp2
📁  Mounting host path /Users/medya/.asdf/ into VM as /tmp1/ ...
    ▪ Mount type:   9p
    ▪ User ID:      docker
    ▪ Group ID:     docker
    ▪ Version:      9p2000.L
    ▪ Message Size: 262144
    ▪ Options:      map[]
    ▪ Bind Address: 192.168.106.1:59806
🚀  Userspace file server: ufs starting
✅  Successfully mounted /Users/medya/.asdf/ to /tmp1/


Manually checked only /tmp1 was inside minikube

@minikube-pr-bot

This comment has been minimized.

@medyagh
Copy link
Member

medyagh commented Jul 22, 2025

@bugwz are you interested to add the same functionality to "minikube mount" command as well so it has feature parity?

@bugwz
Copy link
Author

bugwz commented Jul 23, 2025

@medyagh Thank you for your suggestion. I will continue to improve as per your advice. Stay tuned!😜

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 26, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-sigs/prow repository.

@k8s-ci-robot
Copy link
Contributor

@bugwz: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-minikube-build 82c5e0e link true /test pull-minikube-build

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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-sigs/prow repository. I understand the commands that are listed here.

@bugwz
Copy link
Author

bugwz commented Jul 26, 2025

@medyagh

Hello, I have submitted new changes, please conduct a code review.

The relevant changes are as follows:

  1. Added support for multiple mounts in the mount feature.
  2. Modified documentation for mount and start.

Design approach for minikube mount:

  1. Added Root and RootIdx variables to the Ufs struct of the 9p server to record the hostPaths and index.
  2. Added a root variable to the ufsFid struct of the 9p server to record the mapped hostPath.
  3. Passed the hostPaths as an argument when starting the 9p server.
  4. When the mount -t 9p * command is called sequentially, the 9p server processes the requests from the kernel by calling the Attach function. The Attach function selects Root[RootIdx] based on the execution order and assigns it to the fid.root variable.
  5. Subsequent file and directory operations will parse the value of the fid.root variable.

Although the 9p server processes messages in parallel, our execution of the mount -t 9p * operation is sequential, so theoretically, the final mapping order should not be incorrect.

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 21056) |
+----------------+----------+---------------------+
| minikube start | 49.0s    | 49.3s               |
| enable ingress | 14.9s    | 14.8s               |
+----------------+----------+---------------------+

Times for minikube ingress: 14.9s 15.4s 14.9s 14.5s 14.9s
Times for minikube (PR 21056) ingress: 14.9s 15.0s 14.6s 15.0s 14.4s

Times for minikube start: 48.2s 47.1s 51.0s 49.2s 49.6s
Times for minikube (PR 21056) start: 50.8s 50.7s 48.8s 47.8s 48.5s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 21056) |
+----------------+----------+---------------------+
| minikube start | 23.5s    | 23.6s               |
| enable ingress | 13.2s    | 13.1s               |
+----------------+----------+---------------------+

Times for minikube start: 25.4s 22.8s 21.8s 21.7s 25.9s
Times for minikube (PR 21056) start: 24.8s 22.4s 22.7s 23.4s 24.6s

Times for minikube ingress: 13.3s 12.8s 13.8s 13.3s 12.8s
Times for minikube (PR 21056) ingress: 13.3s 12.8s 13.8s 12.8s 12.8s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 21056) |
+----------------+----------+---------------------+
| minikube start | 23.4s    | 22.4s               |
| enable ingress | 22.9s    | 22.9s               |
+----------------+----------+---------------------+

Times for minikube ingress: 22.8s 22.8s 22.8s 22.8s 23.3s
Times for minikube (PR 21056) ingress: 22.8s 23.3s 22.8s 22.8s 22.8s

Times for minikube start: 25.1s 23.9s 22.1s 23.3s 22.5s
Times for minikube (PR 21056) start: 21.4s 22.5s 21.8s 23.7s 22.7s

@medyagh
Copy link
Member

medyagh commented Jul 28, 2025

@nirs please review this

@bugwz
Copy link
Author

bugwz commented Aug 12, 2025

Is anyone following up?

@nirs
Copy link
Contributor

nirs commented Aug 12, 2025

When using minikube start, we can pass in multiple paths that we want to mount inside the container through the mount-string parameter, for example:

minikube start --mount --mount-string="/data01:/data01;/data02:/data02:Z,rshared"

--mount is not use now. For --mount-string we should not use non standard format like this.

A better way would be to use multiple --mount-string flags using cmd.Flags().StringArray():

--mount-string /dir1:/mnt/dir1[:options]
--mount-string /dir2:/mnt/dir2[:options]

This will be parsed as:

[]string{"/dir1:/mnt/dir1:options", "/dir2:/mnt/dir2:options"}

The advantage is not having to use non-standard separator for users, and having to write special code for parsing the flags.

We ware adding virtiofs support (currently in vfkit and krunkit), so we need to pass options that can work with virtiofs. This should work also with 9p (legacy mount for other drivers), and for podamn/docker we need the special Z option.

We have issues with how --mount-options and other flags like --mount-uid and --mount=guid will be handled. We want to depracate these flags in 1.37 and remove them in 1.38, so options will be specified per mount.

See #21149

@nirs
Copy link
Contributor

nirs commented Aug 12, 2025

minikube mount /.asdf/:/tmp1/;/.vscode/:/tmp2

We should not support such thing, we can accept multiple arguments:

minikube mount "/a:/b" "/c:/d"

But do can we mount multiple mounts with single mount command? It makes sense if we can run single mount server serving multiple commands. If we actually start multiple servers it is better to support one mount argument.

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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants