Skip to content

Commit 56975bc

Browse files
authored
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
1 parent 6d74335 commit 56975bc

File tree

14 files changed

+851
-10
lines changed

14 files changed

+851
-10
lines changed

cmd/minikube/cmd/start_flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func initMinikubeFlags() {
201201
startCmd.Flags().String(network, "", "network to run minikube with. Used by docker/podman, qemu, kvm, and vfkit drivers. If left empty, minikube will create a new network.")
202202
startCmd.Flags().StringVarP(&outputFormat, "output", "o", "text", "Format to print stdout in. Options include: [text,json]")
203203
startCmd.Flags().String(trace, "", "Send trace events. Options include: [gcp]")
204-
startCmd.Flags().Int(extraDisks, 0, "Number of extra disks created and attached to the minikube VM (currently only implemented for hyperkit, kvm2, qemu2, and vfkit drivers)")
204+
startCmd.Flags().Int(extraDisks, 0, "Number of extra disks created and attached to the minikube VM (currently only implemented for hyperkit, kvm2, qemu2, vfkit, and krunkit drivers)")
205205
startCmd.Flags().Duration(certExpiration, constants.DefaultCertExpiration, "Duration until minikube certificate expiration, defaults to three years (26280h).")
206206
startCmd.Flags().String(binaryMirror, "", "Location to fetch kubectl, kubelet, & kubeadm binaries from.")
207207
startCmd.Flags().Bool(disableOptimizations, false, "If set, disables optimizations that are set for local Kubernetes. Including decreasing CoreDNS replicas from 2 to 1. Defaults to false.")
@@ -1011,7 +1011,7 @@ func interpretWaitFlag(cmd cobra.Command) map[string]bool {
10111011
}
10121012

10131013
func checkExtraDiskOptions(cmd *cobra.Command, driverName string) {
1014-
supportedDrivers := []string{driver.HyperKit, driver.KVM2, driver.QEMU2, driver.VFKit}
1014+
supportedDrivers := []string{driver.HyperKit, driver.KVM2, driver.QEMU2, driver.VFKit, driver.Krunkit}
10151015

10161016
if cmd.Flags().Changed(extraDisks) {
10171017
supported := false

hack/jenkins/common.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ case "${DRIVER}" in
145145
vfkit)
146146
echo "vfkit: $(vfkit --version)"
147147
;;
148+
krunkit)
149+
echo "krunkit: $(krunkit --version)"
150+
;;
148151
esac
149152

150153
echo ""
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Copyright 2024 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# This script runs the integration tests on an OSX machine for the Hyperkit Driver
19+
20+
# The script expects the following env variables:
21+
# MINIKUBE_LOCATION: GIT_COMMIT from upstream build.
22+
# COMMIT: Actual commit ID from upstream build
23+
# EXTRA_BUILD_ARGS (optional): Extra args to be passed into the minikube integrations tests
24+
# access_token: The GitHub API access token. Injected by the Jenkins credential provider.
25+
26+
27+
set -ex
28+
29+
ARCH="arm64"
30+
OS="darwin"
31+
DRIVER="krunkit"
32+
JOB_NAME="Krunkit_macOS"
33+
EXTRA_TEST_ARGS=""
34+
EXTERNAL="yes"
35+
36+
brew tap slp/krunkit
37+
brew install krunkit
38+
39+
source common.sh

0 commit comments

Comments
 (0)