Skip to content

Commit

Permalink
Merge pull request #18063 from spowelljr/gvisorArm64
Browse files Browse the repository at this point in the history
addons gvisor: Add arm64 support
  • Loading branch information
spowelljr authored Feb 29, 2024
2 parents f9e3939 + 9a5d814 commit 5ff2939
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/addons/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var Addons = []*Addon{
{
name: "gvisor",
set: SetBool,
validations: []setFn{SupportsAmd64, IsRuntimeContainerd},
validations: []setFn{IsRuntimeContainerd},
callbacks: []setFn{EnableOrDisableAddon, verifyAddonStatus},
},
{
Expand Down
14 changes: 0 additions & 14 deletions pkg/addons/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ package addons

import (
"fmt"
"runtime"
"strconv"

"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/out"
)

Expand Down Expand Up @@ -95,15 +93,3 @@ func contains(slice []string, val string) bool {
}
return false
}

// SupportsAmd64 ensures that the cluster supports running amd64 images
func SupportsAmd64(cc *config.ClusterConfig, name, _ string) error {
// KIC can run amd64 images on a non-amd64 environment
if driver.IsKIC(cc.Driver) {
return nil
}
if runtime.GOARCH == "amd64" {
return nil
}
return fmt.Errorf("the %q addon requires a cluster that supports running amd64 images", name)
}
21 changes: 17 additions & 4 deletions pkg/gvisor/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"os/exec"
"os/signal"
"path/filepath"
"runtime"
"syscall"

"github.com/docker/machine/libmachine/mcnutils"
Expand All @@ -36,17 +37,29 @@ const (
containerdConfigPath = "/etc/containerd/config.toml"
containerdConfigBackupPath = "/tmp/containerd-config.toml.bak"

releaseURL = "https://storage.googleapis.com/gvisor/releases/release/latest/x86_64/"
shimURL = releaseURL + "containerd-shim-runsc-v1"
gvisorURL = releaseURL + "runsc"

configFragment = `
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runsc]
runtime_type = "io.containerd.runsc.v1"
pod_annotations = [ "dev.gvisor.*" ]
`
)

var (
shimURL = releaseURL() + "containerd-shim-runsc-v1"
gvisorURL = releaseURL() + "runsc"
)

func releaseURL() string {
arch := runtime.GOARCH
switch arch {
case "amd64":
arch = "x86_64"
case "arm64":
arch = "aarch64"
}
return fmt.Sprintf("https://storage.googleapis.com/gvisor/releases/release/latest/%s/", arch)
}

// Enable follows these steps for enabling gvisor in minikube:
// 1. creates necessary directories for storing binaries and runsc logs
// 2. downloads runsc and gvisor-containerd-shim
Expand Down

0 comments on commit 5ff2939

Please sign in to comment.