Commit Graph

5 Commits (dependabot/go_modules/golang.org/x/term-0.35.0)

Author SHA1 Message Date
Nir Soffer 890003c584 krunkit: Disable offloading for faster networking
krunkit-1.0.0[1] allows disabling offloading for faster networking. Keep
the Offloading option in case offloading is improved in future versions
or we want to add a flag to use int for specific workload.

Testing shows 6.7 times faster network performance, and 9p mount
is 3 times faster.

Starting cluster:

    % minikube start --driver krunkit --container-runtime containerd
    😄  minikube v1.36.0 on Darwin 15.6 (arm64)
      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.33.2 on containerd 1.7.23 ...
    🔗  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

Testing iperf3:

    % kubectl apply -f iper3-server.yaml
    deployment.apps/iperf3 created
    service/iperf3 created

    % kubectl get deploy iperf3
    NAME     READY   UP-TO-DATE   AVAILABLE   AGE
    iperf3   1/1     1            1           9s

    % kubectl get service iperf3
    NAME     TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
    iperf3   NodePort   10.105.127.180   <none>        5201:30201/TCP   17s

    % iperf3 -c $(minikube ip) -p 30201
    Connecting to host 192.168.105.10, port 30201
    [  5] local 192.168.105.1 port 50630 connected to 192.168.105.10 port 30201
    [ ID] Interval           Transfer     Bitrate
    [  5]   0.00-1.00   sec  1.05 GBytes  9.03 Gbits/sec
    [  5]   1.00-2.01   sec  1.09 GBytes  9.29 Gbits/sec
    [  5]   2.01-3.01   sec  1.06 GBytes  9.09 Gbits/sec
    [  5]   3.01-4.00   sec  1.08 GBytes  9.33 Gbits/sec
    [  5]   4.00-5.00   sec  1.08 GBytes  9.31 Gbits/sec
    [  5]   5.00-6.00   sec  1.07 GBytes  9.23 Gbits/sec
    [  5]   6.00-7.00   sec  1.09 GBytes  9.35 Gbits/sec
    [  5]   7.00-8.01   sec  1.08 GBytes  9.20 Gbits/sec
    [  5]   8.01-9.00   sec  1.07 GBytes  9.18 Gbits/sec
    [  5]   9.00-10.01  sec  1.08 GBytes  9.28 Gbits/sec
    - - - - - - - - - - - - - - - - - - - - - - - - -
    [ ID] Interval           Transfer     Bitrate
    [  5]   0.00-10.01  sec  10.7 GBytes  9.23 Gbits/sec                  sender
    [  5]   0.00-10.01  sec  10.7 GBytes  9.23 Gbits/sec                  receiver

Testing 9p mount:

    % minikube mount ~/models:/mnt/models
    📁  Mounting host path /Users/nir/models into VM as /mnt/models ...
        ▪ Mount type:   9p
        ▪ User ID:      docker
        ▪ Group ID:     docker
        ▪ Version:      9p2000.L
        ▪ Message Size: 262144
        ▪ Options:      map[]
        ▪ Bind Address: 192.168.105.1:50614
    🚀  Userspace file server:
    ufs starting
      Successfully mounted /Users/nir/models to /mnt/models

    📌  NOTE: This process must stay alive for the mount to be accessible ...

    $ time cat /mnt/models/DeepSeek-R1-0528-Qwen3-8B-Q4_K_M.gguf >/dev/null

    real    0m10.219s
    user    0m0.007s
    sys     0m0.263s

[1] https://github.com/containers/krunkit/releases/tag/v1.0.0
2025-09-03 18:14:38 +03:00
Nir Soffer 96229adc41 drivers: Add Virtiofs mounts for vfkit and krunkit
Replace 9p mounts with virtiofs for vfkit and krunkit. Testing shows
that virtiofs mount is 23 times faster with krunkit, and 8 times faster
with vfkit.

vfkit and krunkit support multiple virtiofs mounts but minikube
--mount-* flags are not ready for multiple mounts. We have the same
issue with KIC drivers, supporting multiple mounts but using only one.
We hope to improve this in the next release.

Example usage:

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

The arguments are parsed and validated when configuring the driver, so
invalid arguments fail quickly without starting the driver. The
validated mounts are stored in the machine config:

    $ jq '.Driver.VirtiofsMounts' < ~/.minikube/machines/minikube/config.json
    [
      {
        "HostPath": "/Users/joe/models",
        "GuestPath": "/mnt/models",
        "Tag": "f845b54d-00e3-493d-9541-3b37490b96db"
      }
    ]

Minikube generates a new random UUID for every virtiofs mount to
identify the file system inside the guest. In krunkit and vfkit, every
mount is add as:

    --device virtio-fs,sharedDir=/host-path,mountTag=f845b54d-00e3-493d-9541-3b37490b96db

When the guest is started the shared directory is mounted via SSH using:

    sudo mkdir -p /mnt/models
    sudo mount -t virtiofs f845b54d-00e3-493d-9541-3b37490b96db /mnt/models

Example mount:

    $ minikube ssh findmnt /mnt/models
    TARGET      SOURCE                               FSTYPE   OPTIONS
    /mnt/models f845b54d-00e3-493d-9541-3b37490b96db virtiofs rw,relatime

More work is needed to add VirtioFS to qemu. I'm starting with vfkit and
krunkit since they have identical interface (krunkit was designed as
drop-in replacement for vfkit).
2025-08-20 21:12:45 -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
Nir Soffer 50aaa372b0
krunkit: Fix linter issues (#21133)
I don't know why the linter did not complain in the CI, but running
locally revealed few issues:

    % golangci-lint run ./pkg/drivers/krunkit

    pkg/drivers/krunkit/krunkit.go:537:34: importShadow: shadow of
    imported from 'github.com/docker/machine/libmachine/state' package
    'state' (gocritic)

        func (d *Driver) setKrunkitState(state string) error {
                                     ^
    pkg/drivers/krunkit/krunkit.go:341:9: unnecessary-format:
    unnecessary use of formatting function "fmt.Errorf", you can replace
    it with "errors.New" (revive)

            return fmt.Errorf("hosts without a driver cannot start docker")
                   ^
    pkg/drivers/krunkit/krunkit.go:345:9: unnecessary-format:
    unnecessary use of formatting function "fmt.Errorf", you can replace
    it with "errors.New" (revive)

            return fmt.Errorf("hosts without a driver cannot stop docker")
                   ^
    pkg/drivers/krunkit/krunkit.go:444:18: func (*Driver).logfilePath is
    unused (unused)

        func (d *Driver) logfilePath() string {
                     ^
2025-07-25 15:39:44 -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