Commit Graph

3426 Commits (ae87c281a8e7fc2b75b51b9613ab89640fed3216)

Author SHA1 Message Date
Nir Soffer 0ffd4ccb2f run: Remove viper.GetBool("download-only") checks
Add run.CommandOptions.DownloadOnly option and replace
viper.GetBool("download-only") calls in minikube packages.
2025-10-24 18:11:44 +03:00
Nir Soffer 74b0d69873 notify: Remove viper interactive checks
The notify helpers accept now *run.CommandOptions and use it to check if
we can interact with the user. Modify callers to pass options using
cmd/flags.CommandOptions().
2025-10-24 18:11:44 +03:00
Nir Soffer 4f2a8a17dc firewall: Remove viper interactive check
filewall.UnblockBootpd() accepts now *run.CommandOptions and use it to
check if we can interact with the user. Update callers to pass options.
2025-10-24 18:11:44 +03:00
Nir Soffer b91345db3a vment: Remove viper interactive check
vment.ValidateHelper() accept now *run.CommandOptions and use
options.NonInteractive to check if interaction is allowed.  Update
callers to pass options from the minikube command.

Testing non-interactive mode:

    % sudo rm /etc/sudoers.d/vmnet-helper
    % sudo -k
    % out/minikube start -d krunkit --interactive=false
    😄  minikube v1.37.0 on Darwin 26.0.1 (arm64)
      Using the krunkit (experimental) driver based on user configuration

    🤷  Exiting due to PROVIDER_KRUNKIT_NOT_FOUND: The 'krunkit' provider was not found: exit status 1: sudo: a password is required
    💡  Suggestion: Install and configure vment-helper
    📘  Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/krunkit/

Testing interactive mode:

    % out/minikube start -d krunkit
    😄  minikube v1.37.0 on Darwin 26.0.1 (arm64)
    💡  Unable to run vmnet-helper without a password
        To configure vment-helper to run without a password, please check the documentation:
        https://github.com/nirs/vmnet-helper/#granting-permission-to-run-vmnet-helper
    Password:
      Using the krunkit (experimental) driver based on user configuration
    👍  Starting "minikube" primary control-plane node in "minikube" cluster
    🔥  Creating krunkit VM (CPUs=2, Memory=6144MB, Disk=20000MB) ...
    🐳  Preparing Kubernetes v1.34.1 on Docker 28.4.0 ...
    🔗  Configuring bridge CNI (Container Networking Interface) ...
    🔎  Verifying Kubernetes components...
        ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
    🌟  Enabled addons: default-storageclass, storage-provisioner
    🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
2025-10-24 18:11:44 +03:00
Nir Soffer d98d710fa3 run: Pass command options to drivers
Some drivers need command line options since they need to pass command
line options back to minikube firewall package. The way to pass command
line options to the driver is via the NewDriver function, called by the
registry Loader function.

The registry Loader function is called by machine.LocalClient.Load,
which is part of the limachine API interface, which is not part of
minikube so we cannot change it. We pass the options to
machine.NewAPIClient(), so the client can pass the options to Load().

Some drivers need to validate vment helper in the registry StatusChecker
function, considering the --interactive and --download-only flags. So we
pas the options to the StatusChecker function.

This change create the options in most commands that call
machine.NewAPIClient or registry StatusChecker function and pass the
options down.
2025-10-24 18:11:44 +03:00
Nir Soffer 539567b825 run: Introduce minikube/run and cmd/flags packages
This change introduce the basic infrastructure for passing command line
options from the cmd/minikube/cmd package to other packages.

The cmd/flags package provides the CommandOptions() function returning
run.CommandOptions initialized using viper. This package keeps the
constants for command line options (e.g. "interactive") that we want to
share with various packages without accessing global state via viper.

To use options in drivers code, include CommandOptions in the
CommonDriver struct. The options will be initialized from the command
line options when creating a driver.

The basic idea is to create options in the command:

    options := flags.CommandOptions()

And pass it to other packages, where code will use:

    if options.NonInteractive {

Instead of:

    if viper.GetBool("interactive") {

This is type safe and allows reliable parallel testing.
2025-10-24 18:11:18 +03:00
Nir Soffer 45979b9a72 registry-creds: Fix segfault without config file
In #20255 we added an option to use a configuration file instead of
interactive mode, but the change broke interactive mode. Current
minikube segfaults on start:

    % ./out/minikube addons configure registry-creds
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x1067603dc]

    goroutine 1 [running]:
    k8s.io/minikube/cmd/minikube/cmd/config.processRegistryCredsConfig({0x106858a06, 0x8}, 0x0)
            /Users/nir/src/minikube/cmd/minikube/cmd/config/configure_registry_creds.go:93 +0x2c
    k8s.io/minikube/cmd/minikube/cmd/config.init.func8(0x140001f2b00?, {0x140003a83a0, 0x1, 0x106850650?})
            /Users/nir/src/minikube/cmd/minikube/cmd/config/configure.go:69 +0x24c
    github.com/spf13/cobra.(*Command).execute(0x10a088d40, {0x140003a8350, 0x1, 0x1})
            /Users/nir/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1019 +0x82c
    github.com/spf13/cobra.(*Command).ExecuteC(0x10a084880)
            /Users/nir/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148 +0x384
    github.com/spf13/cobra.(*Command).Execute(...)
            /Users/nir/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071
    k8s.io/minikube/cmd/minikube/cmd.Execute()
            /Users/nir/src/minikube/cmd/minikube/cmd/root.go:174 +0x550
    main.main()
            /Users/nir/src/minikube/cmd/minikube/main.go:95 +0x250

The issue is that loadAddonConfigFile() returns nil if the --config-file
flag is not specified, but the code expects non-nil config, handling
zero value as interactive mode. Fixed by returning zero value config in
this case.

With this change we run the normal interactive flow:

    % ./out/minikube addons configure registry-creds

    Do you want to enable AWS Elastic Container Registry? [y/n]: n

    Do you want to enable Google Container Registry? [y/n]: n

    Do you want to enable Docker Registry? [y/n]: y
    -- Enter docker registry server url: docker.io
    -- Enter docker registry username: nirs
    -- Enter docker registry password:

    Do you want to enable Azure Container Registry? [y/n]: n
      registry-creds was successfully configured

    % out/minikube addons enable registry-creds
      registry-creds is a 3rd party addon and is not maintained or verified by minikube maintainers, enable at your own risk.
      registry-creds does not currently have an associated maintainer.
        ▪ Using image docker.io/upmcenterprises/registry-creds:1.10
    🌟  The 'registry-creds' addon is enabled

Note that this addon does not work on arm64 since we have only amd64
image. The pod fail to start:

    % kubectl logs deploy/registry-creds -n kube-system
    exec /registry-creds: exec format error
2025-10-23 00:20:40 +03:00
Medya Ghazizadeh 4d35aefea7
Merge pull request #21426 from bobsira/fit-windows-unit-tests-chown-trykill
test:  fix TestTryKillOne unit test on windows
2025-10-22 11:42:15 -07:00
Bob Sira 9d74e1f1d9 fix Windows unit test failures for TestTryKillOne 2025-10-21 16:52:52 +01:00
Nir Soffer 7bc97d7ce1 kvm: Convert to internal driver
Remove the docker-machine-driver-kvm2 wrapper and use the kvm driver as
internal driver.

To avoid dependency on libvirt shared library on Linux, we build now
with the libvirt_dlopen build tag. This is used only linux to avoid
linking with libvirt shared library. This is not documnted but can be
found in the source.
f7cdeba997/domain.go (L30)

With this we don't need libvirt devel libraries during build, and in
runtime we will fail if libvirt shared library is not installed.

With this change minikube can not be built for linux !amd64 since building
libvirt go binding requires CGO, and it does not work by changing GOARCH.
2025-10-19 17:20:47 +03:00
Nir Soffer 595bbf5b74 config: Use slices.Contains
Replace searching in slices with slices.Contains() and remove helper
functions and tests.

Continuing modernization effort from #21430.
2025-10-08 16:08:59 +03:00
Medya Ghazizadeh 5906bd3b93 add path to the error msg 2025-09-15 13:44:55 -07:00
Medya Ghazizadeh 786073b515 add err types for not path and not exit 0 2025-09-15 13:08:26 -07:00
Medya Ghazizadeh 17dfd0b058
Merge pull request #21515 from developowl/fix/config-view-long-description
UI: improve config flag long description
2025-09-08 10:11:47 -07:00
Shin Jihoon ed73d2313a fix: change double quotes to backtick 2025-09-09 01:08:55 +09:00
Shin Jihoon d9c9e7d30a fix: config-view-long-description(L43) 2025-09-08 23:49:14 +09:00
Kaviraj Sankameeswaran a068e3b132 refactor: modernize slice operations using slices and maps packages
Replace traditional append-in-loop patterns with modern Go functions slices.Sorted(), slices.Collect(), and maps.Keys()/maps.Values()

Changes made (5 files):
- cmd/minikube/cmd/config/addons_list.go: Use slices.Sorted(maps.Keys())
- cmd/minikube/cmd/version.go: Use slices.Sorted(maps.Keys())
- hack/changelog/changelog.go: Use slices.Collect(maps.Keys())
- pkg/minikube/node/cache.go: Use slices.Collect(maps.Keys())
- pkg/minikube/registry/registry.go: Use slices.Collect(maps.Values())

Files skipped due to complexity:
- pkg/drivers/kic/oci/oci.go
- pkg/drivers/hyperkit/driver.go
- pkg/drivers/kvm/gpu.go
- pkg/drivers/kvm/numa.go [Unrelated slice optimization possible, can be addressed along with other similar code]
- pkg/minikube/tunnel/kic/*
- cmd/minikube/cmd/service.go
- hack/legacy_fill_db/filldb.go

These cases require more sophisticated transformation logic that might be better addressed in separate issue/PR
2025-08-28 11:29:39 -07:00
Predrag Rogic ee80ebace2 skip tests not relevant for windows 2025-08-27 21:08:08 -07:00
Nir Soffer a82e25af0e
start: Simpler and safer mount on start (#21250)
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/
2025-08-11 11:38:58 -07:00
Nir Soffer 62529ec03e
spelling: Fix spelling errors with codespell (#21273)
Fix trivial spelling errors using codespell[1]:

    codespell --skip '*.yaml,*.tmpl,*.json,*.html,*.patch,go.sum' -w

And rejecting some false positives fixes:

    ./CHANGELOG.md:907: fliter ==> filter
    ./third_party/go9p/clnt_write.go:48: Writen ==> Written
    ./third_party/kubeadm/app/features/features.go:69: AtLeast ==> at least
    ./site/content/en/docs/contrib/translations.md:106: certificats ==> certificates
    ./site/content/en/docs/contrib/translations.md:113: espace ==> escape
    ./site/content/en/docs/tutorials/amd.md:75: HSA ==> HAS
    ./site/content/en/docs/tutorials/amd.md:87: HSA ==> HAS
    ./pkg/minikube/config/extra_options_test.go:143: expRes ==> express
    ./pkg/minikube/config/extra_options_test.go:151: expRes ==> express
    ./pkg/minikube/config/extra_options_test.go:152: expRes ==> express
    ./pkg/minikube/config/extra_options_test.go:168: expRes ==> express
    ./pkg/minikube/config/extra_options_test.go:177: expRes ==> express
    ./pkg/minikube/config/extra_options_test.go:178: expRes ==> express

There are more spelling errors that need manual selection:

    ./CHANGELOG.md:234: issuse ==> issue, issues
    ./CHANGELOG.md:543: Pris ==> Prise, Prism
    ./hack/benchmark/time-to-k8s/page.go:73: readin ==> reading, read in
    ./hack/benchmark/image-build/generate-chart.go:82: INTERATIVE ==> INTERACTIVE, ITERATIVE
    ./hack/benchmark/image-build/generate-chart.go:87: INTERATIVE ==> INTERACTIVE, ITERATIVE
    ./hack/benchmark/image-build/generate-chart.go:137: INTERATIVE ==> INTERACTIVE, ITERATIVE
    ./hack/benchmark/image-build/generate-chart.go:162: interative ==> interactive, iterative
    ./hack/benchmark/image-build/generate-chart.go:195: INTERATIVE ==> INTERACTIVE, ITERATIVE
    ./third_party/go9p/fmt.go:132: Tread ==> Thread, Treat
    ./third_party/go9p/fmt.go:133: Tread ==> Thread, Treat
    ./third_party/go9p/p9.go:33: Tread ==> Thread, Treat
    ./third_party/go9p/p9.go:170: Tread ==> Thread, Treat
    ./third_party/go9p/p9.go:171: Tread ==> Thread, Treat
    ./third_party/go9p/p9.go:225: Tread ==> Thread, Treat
    ./third_party/go9p/p9.go:263: Tread ==> Thread, Treat
    ./third_party/go9p/packt.go:165: Tread ==> Thread, Treat
    ./third_party/go9p/packt.go:168: Tread ==> Thread, Treat
    ./third_party/go9p/srv_srv.go:305: Tread ==> Thread, Treat
    ./third_party/go9p/srv_srv.go:349: Tread ==> Thread, Treat
    ./third_party/go9p/unpack.go:170: Tread ==> Thread, Treat
    ./site/content/en/docs/tutorials/multi_control_plane_ha_clusters.md:145: Virual ==> Virtual, Visual, Viral
    ./pkg/drivers/krunkit/krunkit.go:392: Terminte ==> Terminate, Termite
    ./pkg/drivers/common/common.go:283: drawin ==> drawing, draw in, drawn
    ./pkg/drivers/kic/oci/oci.go:175: stroed ==> stored, stroked, strode
    ./pkg/minikube/out/out.go:412: isT ==> is, it, its, it's, sit, list
    ./pkg/minikube/out/out.go:413: isT ==> is, it, its, it's, sit, list
    ./pkg/minikube/out/out.go:414: isT ==> is, it, its, it's, sit, list
    ./pkg/minikube/shell/shell_test.go:152: writed ==> wrote, written, write, writer
    ./pkg/minikube/bootstrapper/kubeadm/kubeadm.go:710: wil ==> will, well

If we find a way to prevent the false positives we can use this command
for spell checking in the CI.

[1] https://github.com/codespell-project/codespell
2025-08-11 11:27:20 -07:00
Nir Soffer 5d4d03623b
drivers: Extract drivers/common package (#21266)
Move all files and packages which are not a driver to the drivers/common
package. This helps to understand the structure of the code.

While moving, move the iso_test.iso into testdata/test.iso to separate
code and test data.

While fixing the test iso path fix few bugs in the tests using wrong iso
path. The test failed because the iso path was wrong instead of issue
with source or destination path.

New directory structure:

    % tree -L1 pkg/drivers
    pkg/drivers
    ├── common
    ├── hyperkit
    ├── kic
    ├── krunkit
    ├── kvm
    ├── none
    ├── qemu
    ├── ssh
    └── vfkit
2025-08-08 22:50:57 -07:00
Aaron Nall fc70407316
Add support to docker runtime for OCI access to NVIDIA GPUs (#20959)
* Add support for --device=nvidia.com/gpu=all

* Add "nvidia.com" to valid options for gpus flag in TestValidateGPUs.
2025-08-07 11:23:31 -07:00
minikube-bot cbcc66f84f
Update go-github from v73.0.0 to v74.0.0 (#21234) 2025-08-04 12:36:45 -07:00
Jun Sugimoto 14dfcee1ab
Add --disable-coredns-log flag (#20992) 2025-07-30 11:52:57 -07:00
Victor Ubahakwe 958ecac9d3
Refactor table rendering (#20893)
* Refactored table rendering codes to support updated tablewriter v1.0.7

This commit makes all necessary code changes to maintain compatibility
with the new tablewriter version. The update includes several required modifications across multiple files.

Files modified:
- cmd/minikube/cmd/config/images.go
- cmd/minikube/cmd/config/addons_list.go
- cmd/minikube/cmd/config/profile_list.go
- hack/benchmark/time-to-k8s/chart.go
- hack/benchmark/time-to-k8s/cpu.go
- pkg/minikube/audit/row.go
- pkg/minikube/machine/cache_images.go
- pkg/minikube/perf/result_manager.go
- pkg/minikube/service/service.go

Now #20878 can be merged.
Addresses #20879

* The tablewriter package v1.0.7 renamed SetHeaders to SetHeader

* updated go mod and table.SetColumnAlignment([]int{0, 0, 0, 0})

* Changed syntax and added vendor to gitignore

* simplified version of tablewriter

* removed vendor

* fix addon_list

* fix images tablewrtier

* bump tablewriter for profile list

* go mod tidy

* bump tablewriter for chart

* bump tablewriter for cpu chart

* bump tablewriter for row

* bump tablewriter cache images

* bump tablewriter

* bump tablewriter

* revert file

* bump tablewritter

* fix unit test

* fix lint issues

* fix the integration test pipe char

* convert all tables to new pipe instead of asci pipe

* convert all tables to new pipe instead of asci pipe

* go mod tidy

* go work sync

---------

Co-authored-by: Medya Ghazizadeh <medya@google.com>
2025-07-21 16:20:55 -07:00
Nir Soffer 56975bc752
Add krunkit driver supporting GPU acceleration on macOS (#20826)
* krunkit: Add krunkit driver

krunkit is a tool to launch configurable virtual machines using the
libkrun platform, optimized for GPU accelerated virtual machines and AI
workloads on Apple silicon.

It is mostly compatible with vfkit; the driver is a simplified copy of
the vfkit driver. Unlike vfkit, krunkit is available only on Apple
silicon.

Changes compared to vfkit driver:
- krunkit requires unix socket for networking, so we must use
  vment-helper.
- krunkit does not support HardStop, so we kill it using SIGKILL.
- We must enable vmnet offloading, required for krunkit.
- The code was simplified since vmnet-helper is always used
- Code was cleaned up to use .ResolveStorePath()
- Unused Upgrade() function was removed
- Types and functions that should not be public made private

We require krunkit 0.2.2, supporting --restul-uri=unix://.

* reason: Make vment-helper error driver agnostic

Previously it was used only for vfkit, so we suggested to fallback to
the `nat` network. This advice is not relevant to krunkit or to qemu
(which can also use vmnet-helper).

Change the error to recommend installing vment-helper. We need to think
how we can recommend other networks for vfkit and qemu. Another solution
is to create error for every driver+network combination but this seems
hard to manage.

* hack: Add krunkit integration test

This is the same way that we test vfkit. This test is not running in the
CI.

Issues:
- Need to install and configure vment-helper (requires root).

* site: Add krunkit driver documentation
2025-07-21 12:59:28 -07:00
Divy Singhvi 2a49119c55
Deprecate HyperKit driver with warning (#21024)
* deprecate hyperkit driver with user-facing warning

* apply review suggestions from PR #21024

* apply review suggestions from PR #21024

* apply review suggestions from PR #21024-updating registery priority
2025-07-14 14:04:10 -07:00
minikube-bot 4b06829b8b
Update go-github from v72.0.0 to v73.0.0 (#21000) 2025-06-30 10:55:33 -07:00
Imran Pochi 21d0a4d2a2
docs: clarify --addons flag description (#20954)
Signed-off-by: Imran Pochi <imranpochi@microsoft.com>
2025-06-25 11:16:03 -07:00
Tian 017ef750b3
redo "minikube profile list" to move the verbose details into a --detailed flag (#20544) 2025-06-06 10:32:34 -07:00
Predrag Rogic 945b43609c
don't call startKicServiceTunnel for non-kic drivers (#20863)
* don't call startKicServiceTunnel for non-kic drivers

* warn about exposing ClusterIP services for all drivers
2025-06-04 11:31:39 -07:00
Predrag Rogic 4da3cedc84
Fix KVM driver (tests) timeouts (#20852)
* Fix KVM driver tests timeouts

Rewrite KVM driver waiting logic for domain start, getting ip address
and shutting domain down. Add more config/state outputs to aid future
debugging.

Bump go/libvirt to v1.11002.0 and set the minimum memory required for
running all tests to 3GB to avoid some really weird system behaviour.

* revert reduction of timelimit for TestCert tests run

* set memory and debug output in TestNoKubernetes tests

* extend kvm waitForStaticIP timeout

* add console log to debug output

* Updating ISO to v1.36.0-1748823857-20852

---------

Co-authored-by: minikube-bot <minikube-bot@google.com>
2025-06-03 15:07:48 -07:00
Medya Ghazizadeh f439f0c3a4
add short hand -m for --memory (#20854)
* add short hand -m for --memory

* hide deperecated flags
2025-05-29 10:16:02 -07:00
Tian 3cf1e63e21
build: address all lint issues by v2 (#20804)
* fix QF1011: could omit type *os.File from declaration; it will be inferred from the right-hand side

* fix QF1012: Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...))

* fix QF1001: could apply De Morgan's law

* fix QF1003: could use tagged switch

* fix weakCond: suspicious ; nil check may not be enough, check for len (gocritic)

* fix docStub: silencing go lint doc-comment warnings is unadvised

* fix builtinShadow: shadowing of predeclared identifier: error

* fix importShadow: shadow of imported package

* fix nestingReduce: invert if cond, replace body with , move old body after the statement

* useless-break: useless break in case clause (revive)

* Clear the redundant content in golangci.yaml file
2025-05-23 17:31:28 -07:00
Nir Soffer 56ed2662b0
vfkit: Minor docs, test, and help fixes (#20815)
* vfkit: Fix help text for --extra-disks

vfkit can use extra disks but we forgot to mention it in the help text.

* vfkit: Remove stale tap

vfkit in cfergeau/crc will no longer be updated now that it’s in the main repo.

* vfkit: Fix status in index

The vfkit driver is preferred now.
2025-05-21 20:30:26 -07:00
Sri Panyam 7b97f424c7
New flag to allow option for passing a config file for addon configure command. (#20255)
* Addon configuration now takes an optional config file to load from
instead of forcing prompts

Fixes #20124

* Using a rarer value for default instead of changeme so it has less chance to interfere with other possible user defaults

* Fixing expected values of test cases

* making addonConfigFile private

* Keeping registry_creds configs together.

* Starting a typed AddonConfig struct so each addon con loads its
  configs in a typed way.
* Started configs for RegistryCreds using this convention and moved
  registry_creds config processing to its own file
  (configure_registry_creds.go)

* Making registry creds structs private and other PR feedback cleanups

* Changing default value back to 'changeme'

* Simplifying duplicate consts

* Adding missed comma

* lint fixes

* Generating docs

* Copyright for new file
2025-05-13 11:05:48 -07:00
minikube-bot bc4a5b8276
Update go-github from v71.0.0 to v72.0.0 (#20729) 2025-05-13 10:08:46 -07:00
Nir Soffer e4bdba7e5d
vmnet: Support running without sudoers configuration (#20719)
* vmnet: Improve --network vmnet-shared validation

Previously we did not check that the helper can run with the
--close-from=4 option, so the command could succeed when incorrect
sudoers configuration. For example a user with liberal NOPASSWD rule,
but without the closefrom_override option.

When the check failed, we log unhelpful log:

    libmachine: Failed to run vmnet-helper:
    %!w(*exec.ExitError=&{0x14000135e30 [115 117 100 111 58 32 97 ... 101 100 10]})

And we returned a bool, so the caller could not provide a suggestion how
to resolve the issue.

Fix by:

- Rename vment.HelperAvaialble to vment.ValidateHelper
- Return an error describing the issue, including a reason.Kind that can
  be used to provide a suggestion for resolving the issue.
- Include the ExitError.Stderr int the error. This includes helpful
  error messages from sudo.
- Add new reason.NotConfiguredVmnetHelper error
- Improve log when vment.ValidateHelper() succeeded

Example error flow - vment-helper not installed:

    % minikube start --driver vfkit --network vmnet-shared
    😄  minikube v1.35.0 on Darwin 15.4.1 (arm64)
      Using the vfkit (experimental) driver based on user configuration

    🙈  Exiting due to NOT_FOUND_VMNET_HELPER: failed to validate vmnet-shared network:
    stat /opt/vmnet-helper/bin/vmnet-helper: no such file or directory
    💡  Suggestion:

        vmnet-helper was not found on the system, resolve by:

        Option 1) Installing vmnet-helper:

        https://github.com/nirs/vmnet-helper#installation

        Option 2) Using the nat network:

        minikube start<no value> --driver vfkit --network nat

I resolved the issue by installing vmnet-helper but I did not configured
the sudoers rule:

    % minikube start --driver vfkit --network vmnet-shared
    😄  minikube v1.35.0 on Darwin 15.4.1 (arm64)
      Using the vfkit (experimental) driver based on user configuration

    🙈  Exiting due to NOT_CONFIGURED_VMNET_HELPER: failed to validate vmnet-shared network:
    exit status 1: sudo: you are not permitted to use the -C option
    💡  Suggestion:

        Configure vmnet-helper to run without a password.

        Please install a vmnet-helper sudoers rule using these instructions:

        https://github.com/nirs/vmnet-helper#granting-permission-to-run-vmnet-helper

After installing the sudoers rule minikube could start.

* vfkit: Use helper --socket instead of --fd

The --fd option avoids the need to manage a bound unix sockets, in
particular the limit on unix socket length. It is also more secure;
only the process inheriting the socket can access the helper. However it
requires the sudo --close-from= option, which may not work for some
users. We don't understand why it does not work, and debugging it is
hard since users are not happy to share their local sudoers
configuration.

Avoid the trouble by switching to the --socket option. In this case we
pass a unix socket path to the helper and vfkit. The helper creates a
bound unix datagram socket in the specified path, and waits until vfkit
connects to the socket. When vfkit connects to the unix socket the
programs are connected in the same way they are connected by passing
file descriptors.

When running minikube we will see 3 new files in the machine directory:

- `vfkit-fb64-7802.sock`: vfkit unix datagram socket
- `vmnet-helper.sock`: vmnet-helper unix datagram socket
- `vmnet-helper.sock.lock`: lockfile for vment-helper socket

The files are deleted when vmnet-helper and vfkit are terminated
gracefully. If they are killed the stale files are replaced on the next
start.

Issues:
- If the path exceeds the limit (104 characters), opening the socket
  will fail. We have the sames issue with vfkit management socket.

* vment: Fallback to interactive sudo

If vmnet-helper sudoers rule is not configured or does not work for the
user, maybe because the user has disabled the NOPASSWD option, we used
to fail, recommending to configure vmnet sudoers rule. This does not
help a user that cannot fix the sudoers configuration.

Since we switched to --socket mode, we can work without a sudoers rule.
If we can interact with the user, we fall back to interactive sudo. The
user can enter a password to start the machine.

Example run with --interactive=false:

    % minikube start --driver vfkit --network vmnet-shared --interactive=false
    😄  minikube v1.35.0 on Darwin 15.4.1 (arm64)
      Using the vfkit (experimental) driver based on user configuration

    🙈  Exiting due to NOT_CONFIGURED_VMNET_HELPER: failed to validate vmnet-shared network:
    exit status 1: sudo: a password is required
    💡  Suggestion:

        Configure vmnet-helper to run without a password.

        Please install a vmnet-helper sudoers rule using these instructions:

        https://github.com/nirs/vmnet-helper#granting-permission-to-run-vmnet-helper

Example run with --interactive (default):

    % minikube start --driver vfkit --network vmnet-shared
    😄  minikube v1.35.0 on Darwin 15.4.1 (arm64)
      Using the vfkit (experimental) driver based on user configuration
    💡  Unable to run vmnet-helper without a password
        To configure vment-helper to run without a password, please check the documentation:
        https://github.com/nirs/vmnet-helper/#granting-permission-to-run-vmnet-helper
    Password:
    👍  Starting "minikube" primary control-plane node in "minikube" cluster
    🔥  Creating vfkit VM (CPUs=2, Memory=6000MB, Disk=20000MB) ...
    🐳  Preparing Kubernetes v1.33.0 on Docker 27.4.0 ...
        ▪ 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
2025-05-12 16:44:32 -07:00
Nir Soffer 55b88a6763
Shared network for vfkit driver using vmnet-helper (#20501)
* vfkit: Remove temporary variable

Remove temporary and unneeded mac variable. It is easier to follow the
code when we use d.MACAddress.

* vfkit: Promote state change to INFO level

System state changes should be more visible to make debugging easier.

* vmnet: Add vmnet package

The package manages the vmnet-helper[1] child process, providing
connection to the vmnet network without running the guest as root.

We will use vmnet-helper for the vfkit driver, which does not have a way
to use shared network, when guests can access other guest in the
network.  We can use it later with the qemu driver as alternative to
socket_vmnet.

[1] https://github.com/nirs/vmnet-helper

* vfkit: add vmnet-shared network

Add new network option for vfkit "vmnet-shared", connecting vfkit to the
vmnet shared network. Clusters using this network can access other
clusters in the same network, similar to socket_vmnet with QEMU driver.

If network is not specified, we default to the "nat" network, keeping
the previous behavior. If network is "vmnet-shared", the vfkit driver
manages 2 processes: vfkit and vmnet-helper.

Like vfkit, vmnet-helper is started in the background, in a new process
group, so it not terminated if the minikube process group is terminate.

Since vmnet-helper requires root to start the vmnet interface, we start
it with sudo, creating 2 child processes. vmnet-helper drops privileges
immediately after starting the vmnet interface, and run as the user and
group running minikube.

Stopping the cluster will stop sudo, which will stop the vmnet-helper
process. Deleting the cluster kill both sudo and vmnet-helper by killing
the process group.

This change is not complete, but it is good enough to play with the new
shared network.

Example usage:

1. Install vmnet-helper:
   https://github.com/nirs/vmnet-helper?tab=readme-ov-file#installation

2. Setup vmnet-helper sudoers rule:
   https://github.com/nirs/vmnet-helper?tab=readme-ov-file#granting-permission-to-run-vmnet-helper

3. Start 2 clusters with vmnet-shared network:

    % minikube start -p c1 --driver vfkit --network vmnet-shared
    ...

    % minikube start -p c2 --driver vfkit --network vmnet-shared
    ...

    % minikube ip -p c1
    192.168.105.18

    % minikube ip -p c2
    192.168.105.19

4. Both cluster can access the other cluster:

    % minikube -p c1 ssh -- ping -c 3 192.168.105.19
    PING 192.168.105.19 (192.168.105.19): 56 data bytes
    64 bytes from 192.168.105.19: seq=0 ttl=64 time=0.621 ms
    64 bytes from 192.168.105.19: seq=1 ttl=64 time=0.989 ms
    64 bytes from 192.168.105.19: seq=2 ttl=64 time=0.490 ms

    --- 192.168.105.19 ping statistics ---
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 0.490/0.700/0.989 ms

    % minikube -p c2 ssh -- ping -c 3 192.168.105.18
    PING 192.168.105.18 (192.168.105.18): 56 data bytes
    64 bytes from 192.168.105.18: seq=0 ttl=64 time=0.289 ms
    64 bytes from 192.168.105.18: seq=1 ttl=64 time=0.798 ms
    64 bytes from 192.168.105.18: seq=2 ttl=64 time=0.993 ms

    --- 192.168.105.18 ping statistics ---
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 0.289/0.693/0.993 ms

* reason: Remove trailing whitepsace

Trailing whitespace is removed by some editors or displayed as a
warning. Clean up to make it easy to make maintain this file.

* start: Validate vfkit --network option

The vfkit driver supports now `nat` and `vmnet-shared` network options.
The `nat` option provides the best performance and is always available,
so it is the default network option. The `vmnet-shared` option provides
access between machines with lower performance compared to `nat`.

If `vment-shared` option is selected, we verify that vmnet-helper is
available. The check ensure that vmnet-helper is installed and sudoers
configuration allows the current user to run vment-helper without a
password.

If validating vment-helper failed, we return a new NotFoundVmnetHelper
reason pointing to vment-helper installation docs or recommending to use
`nat`. This is based on how we treat missing socket_vmnet for QEMU
driver.

* site: Document vfkit network options
2025-05-01 13:26:48 -04:00
Predrag Rogic c8a63fa11f
Fix waiting for all pods having specified labels to be Ready (#20315)
* Fix waiting for all kube-system pods having one of specified labels to be Ready

* Fix waiting for all kube-system pods having one of specified labels to be Ready

* Fix waiting for all kube-system pods having one of specified labels to be Ready
2025-04-28 14:58:02 -04:00
minikube-bot a4059331a0
Update go-github from v70.0.0 to v71.0.0 (#20618) 2025-04-15 13:28:27 -07:00
minikube-bot 4d2cdae349
Update go-github from v69.2.0 to v70.0.0 (#20561) 2025-03-24 11:13:19 -07:00
minikube-bot 2c8eb82eb0 Update go-github from v68.0.0 to v69.0.0 2025-02-10 10:03:15 +00:00
minikube-bot 5a1b391fb0
Update go-github from v67.0.0 to v68.0.0 (#20174) 2024-12-30 10:24:00 -08:00
錦南路之花 52cd866cd5
auto-pause: restart service after configuration (#19900) 2024-12-11 10:17:34 -08:00
minikube-bot 89125cae14 Update go-github from v66.0.0 to v67.0.0 2024-12-02 10:03:26 +00:00
Steven Powell e679c4a8f6 Fix panic when no services in namespace with --all specified 2024-11-12 12:28:20 -05:00
fbyrne 50b5d8ee62 Add support for AMD GPU via --gpu=amd for docker linux amd64. 2024-10-11 21:36:06 +01:00
Steven Powell 42cbdf6ec6
Add instructions to resolve docker context error (#19197) 2024-10-09 11:36:38 -07:00
minikube-bot ffb751821c Update go-github from v65.0.0 to v66.0.0 2024-10-07 10:03:02 +00:00