Merge pull request #16756 from spowelljr/gvisorArm64

gvisor addon: Only allow on clusters that support running amd64 images
pull/16863/merge
Medya Ghazizadeh 2023-07-10 11:41:59 -07:00 committed by GitHub
commit a10c3fc684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -71,7 +71,7 @@ var Addons = []*Addon{
{
name: "gvisor",
set: SetBool,
validations: []setFn{IsRuntimeContainerd},
validations: []setFn{SupportsAmd64, IsRuntimeContainerd},
callbacks: []setFn{EnableOrDisableAddon, verifyAddonStatus},
},
{

View File

@ -18,12 +18,14 @@ 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"
)
@ -93,3 +95,15 @@ 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)
}