Skip to content

Conversation

nirs
Copy link
Contributor

@nirs nirs commented Aug 5, 2025

The --mount-string argument defaults to /Users on darwin, and homedir.Homedir() on other platforms (e.g. $HOME on unix).

This is wrong in many ways:

  • /Users is not $HOME on darwin (the right path is /Users/$USER). Using the default mount we cannot access anything inside the guest in the user home directory. We can access the special /Users/Shared directory, but this should not be a default mount.

  • Mounting the user home directory inside the guest in read-write mode is a horrible default. This exposes the users private keys in .ssh/ to the guest, any sensitive files in the user home directory, and allows the guest to change any file on the host.

  • Using the --mount option mounts the default mount directory silently. This is unexpected, surprising, and not documented in the minikube handbook[1].

Example access to user private key from the guest with the default mount:

$ minikube start --mount

$ minikube ssh cat /minikube-host/.ssh/id_ed25519
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----

Fixed by removing the default mount directory and changing mount logic to check for non-empty mount-string instead of the mount flag.

The mount flag is kept for backward compatibility, but its value is ignored. In the next release we want to use this flag for supporting multiple mounts.

Example usage before:

minikube start --mount --mount-string ~/models:/mnt/models

Example usage after:

minikube start --mount-string ~/models:/mnt/models

Breaking changes:

User depending the default mount will have to replace the command:

minikube start --mount

With:

minikube start  --mount-string $HOME:/minikube-host

[1] https://minikube.sigs.k8s.io/docs/handbook/mount/

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 5, 2025
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 5, 2025
@nirs
Copy link
Contributor Author

nirs commented Aug 5, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Aug 5, 2025
@medyagh
Copy link
Member

medyagh commented Aug 5, 2025

I agree, we should not mount the home folder to ppl's minikubes by default that was a horrible default of some drivers. I am okay with breaking change if we can get rid of it by default

@minikube-pr-bot

This comment has been minimized.

@nirs nirs marked this pull request as draft August 6, 2025 12:06
@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 Aug 6, 2025
@nirs nirs force-pushed the fix-default-mount branch from b437fb3 to 8191cbc Compare August 9, 2025 00:12
@nirs nirs marked this pull request as ready for review August 9, 2025 00:12
@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 Aug 9, 2025
@k8s-ci-robot k8s-ci-robot requested a review from medyagh August 9, 2025 00:12
@nirs
Copy link
Contributor Author

nirs commented Aug 9, 2025

Changes in latest version:

  • Fix TestMountStart to use --mount-string instead of --mount
  • Rebase on master

@minikube-pr-bot

This comment has been minimized.

@nirs nirs force-pushed the fix-default-mount branch from 8191cbc to e3ec7fd Compare August 9, 2025 03:43
@minikube-pr-bot

This comment has been minimized.

@nirs nirs force-pushed the fix-default-mount branch from e3ec7fd to 13ef2a7 Compare August 9, 2025 13:23
@minikube-pr-bot

This comment has been minimized.

@nirs
Copy link
Contributor Author

nirs commented Aug 9, 2025

/retest

@nirs
Copy link
Contributor Author

nirs commented Aug 9, 2025

/cc @afbjorklund

@nirs
Copy link
Contributor Author

nirs commented Aug 9, 2025

/kind improvement

@k8s-ci-robot k8s-ci-robot added the kind/improvement Categorizes issue or PR as related to improving upon a current feature. label Aug 9, 2025
@nirs
Copy link
Contributor Author

nirs commented Aug 9, 2025

/kind api-change

@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Aug 9, 2025
@nirs
Copy link
Contributor Author

nirs commented Aug 9, 2025

/remove-kind api-change

@k8s-ci-robot k8s-ci-robot removed the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Aug 9, 2025
@@ -173,8 +173,8 @@ func initMinikubeFlags() {
startCmd.Flags().Bool(keepContext, false, "This will keep the existing kubectl context and will create a minikube context.")
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().Bool(createMount, false, "Kept for backward compatibility, value is ignored.")
Copy link
Member

Choose a reason for hiding this comment

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

we can consider hiding this flag (we have a few flags that hidden since we dont want ppl to use them, but left for backward campatiblitiy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hiding the flag will hide the useful help message. I think we should keep if for now. If we don't use it in the next releases we can hide it.

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.

Question: does this mean we need to update this site page about "built-in host folder sharing"?
Driver mounts
Some hypervisors, have built-in host folder sharing. Driver mounts are reliable with good performance, but the paths are not predictable across operating systems or hypervis

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

@nirs
Copy link
Contributor Author

nirs commented Aug 9, 2025

Question: does this mean we need to update this site page about "built-in host folder sharing"? Driver mounts Some hypervisors, have built-in host folder sharing. Driver mounts are reliable with good performance, but the paths are not predictable across operating systems or hypervis

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

This change does not effect built in mounts - these are not done using 9p so they should not be affected by ignoring the --mount flag. These should be disable by --disable-driver-mounts which we did not touch.

So I don't think any update is needed, the only change is the detail of using --mount flag which is not documented in the handbook.

@nirs nirs force-pushed the fix-default-mount branch from 13ef2a7 to 637b1d8 Compare August 9, 2025 23:44
@minikube-pr-bot

This comment has been minimized.

The --mount-string argument defaults to `/Users` on darwin, and
homedir.Homedir() on other platforms (e.g. $HOME on unix).

This is wrong in many ways:

- `/Users` is not HOME on darwin (the right path is `/Users/$USER`).
  Using the default mount we cannot access anything inside the guest in
  the user home directory.  We can access the special `/Users/Shared`
  directory, but this should not be a default mount.

- Mounting the user home directory inside the guest in read-write mode
  is a horrible default. This exposes the users private keys in .ssh/ to
  the guest, any sensitive files in the user home directory, and allows
  the guest to change any file on the host.

- Using the `--mount` option mount the default mount directory silently.
  This is unexpected, surprising, and not documented in the minikube
  handbook[1].

Example access to user private key from the guest with the default
mount:

    $ minikube start --mount

    $ minikube ssh cat /minikube-host/.ssh/id_ed25519
    -----BEGIN OPENSSH PRIVATE KEY-----
    ...
    -----END OPENSSH PRIVATE KEY-----

Fixed by removing the default mount directory and changing mount logic
to check for non-empty mount-string instead of the mount flag.

The mount flag is kept for backward compatibility, but its value is
ignored. In the next release we want to use this flag for supporting
multiple mounts.

Example usage before:

    minikube start --mount --mount-string ~/models:/mnt/models

Example usage after:

    minikube start --mount-string ~/models:/mnt/models

Breaking changes:

User depending the default mount will have to replace the command:

    minikube start --mount

With:

    minikube start  --mount-string $HOME:/minikube-host

[1] https://minikube.sigs.k8s.io/docs/handbook/mount/
@nirs nirs force-pushed the fix-default-mount branch from 637b1d8 to af7362d Compare August 10, 2025 01:30
@nirs
Copy link
Contributor Author

nirs commented Aug 10, 2025

Rebased to consume the docker service fix

@minikube-pr-bot

This comment has been minimized.

@medyagh
Copy link
Member

medyagh commented Aug 10, 2025

/retest-this-please

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21250 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 47.7s    │ 48.9s                  │
│ enable ingress │ 14.8s    │ 15.0s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 47.8s 48.8s 46.8s 45.9s 49.3s
Times for minikube (PR 21250) start: 46.4s 49.6s 51.4s 48.0s 49.1s

Times for minikube ingress: 14.9s 14.9s 14.9s 14.4s 14.9s
Times for minikube (PR 21250) ingress: 14.9s 14.9s 14.9s 14.9s 15.5s

docker driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21250 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 23.1s    │ 23.2s                  │
│ enable ingress │ 12.9s    │ 12.5s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 22.6s 23.4s 24.6s 23.5s 21.5s
Times for minikube (PR 21250) start: 25.4s 21.0s 22.7s 21.9s 24.9s

Times for minikube (PR 21250) ingress: 12.3s 13.2s 12.7s 11.2s 13.2s
Times for minikube ingress: 12.7s 13.7s 13.2s 12.2s 12.7s

docker driver with containerd runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21250 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 23.0s    │ 22.9s                  │
│ enable ingress │ 23.3s    │ 24.3s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 24.6s 23.4s 22.8s 22.5s 21.5s
Times for minikube (PR 21250) start: 21.6s 22.2s 23.3s 22.8s 24.4s

Times for minikube ingress: 23.2s 23.7s 23.7s 23.2s 22.7s
Times for minikube (PR 21250) ingress: 22.7s 23.2s 30.2s 22.7s 22.7s

@nirs
Copy link
Contributor Author

nirs commented Aug 11, 2025

/retest

@@ -173,8 +173,8 @@ func initMinikubeFlags() {
startCmd.Flags().Bool(keepContext, false, "This will keep the existing kubectl context and will create a minikube context.")
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().Bool(createMount, false, "Kept for backward compatibility, value is ignored.")
Copy link
Member

Choose a reason for hiding this comment

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

help text, this will be depricated and merged with --mount-string in the next version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #21291, I'll try to get this into 1.37.

@medyagh medyagh changed the title start: Simpler and safer mount on start dont require both --mount for using --mount-string and remove default mounted folders Aug 11, 2025
@medyagh medyagh changed the title dont require both --mount for using --mount-string and remove default mounted folders Don't require both --mount for using --mount-string and remove default mounted folders Aug 11, 2025
@medyagh
Copy link
Member

medyagh commented Aug 11, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 11, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh, nirs

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

The pull request process is described 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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 11, 2025
@medyagh medyagh merged commit a82e25a into kubernetes:master Aug 11, 2025
28 of 39 checks passed
@nirs nirs deleted the fix-default-mount branch August 12, 2025 00:05
@nirs nirs changed the title Don't require both --mount for using --mount-string and remove default mounted folders Don't require both --mount for using --mount-string and remove default mount-string Aug 12, 2025
pavansaikrishna78 pushed a commit to pavansaikrishna78/minikube that referenced this pull request Aug 18, 2025
The --mount-string argument defaults to `/Users` on darwin, and
homedir.Homedir() on other platforms (e.g. $HOME on unix).

This is wrong in many ways:

- `/Users` is not HOME on darwin (the right path is `/Users/$USER`).
  Using the default mount we cannot access anything inside the guest in
  the user home directory.  We can access the special `/Users/Shared`
  directory, but this should not be a default mount.

- Mounting the user home directory inside the guest in read-write mode
  is a horrible default. This exposes the users private keys in .ssh/ to
  the guest, any sensitive files in the user home directory, and allows
  the guest to change any file on the host.

- Using the `--mount` option mount the default mount directory silently.
  This is unexpected, surprising, and not documented in the minikube
  handbook[1].

Example access to user private key from the guest with the default
mount:

    $ minikube start --mount

    $ minikube ssh cat /minikube-host/.ssh/id_ed25519
    -----BEGIN OPENSSH PRIVATE KEY-----
    ...
    -----END OPENSSH PRIVATE KEY-----

Fixed by removing the default mount directory and changing mount logic
to check for non-empty mount-string instead of the mount flag.

The mount flag is kept for backward compatibility, but its value is
ignored. In the next release we want to use this flag for supporting
multiple mounts.

Example usage before:

    minikube start --mount --mount-string ~/models:/mnt/models

Example usage after:

    minikube start --mount-string ~/models:/mnt/models

Breaking changes:

User depending the default mount will have to replace the command:

    minikube start --mount

With:

    minikube start  --mount-string $HOME:/minikube-host

[1] https://minikube.sigs.k8s.io/docs/handbook/mount/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/mount cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/improvement Categorizes issue or PR as related to improving upon a current feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

5 participants