Merge pull request #11981 from de-sh/vb-warn

Add message to discourage the use of the virtualbox driver
pull/12061/head
Medya Ghazizadeh 2021-07-26 17:30:38 -07:00 committed by GitHub
commit 3375c39c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 0 deletions

View File

@ -126,6 +126,10 @@ var settings = []Setting{
name: config.WantNoneDriverWarning,
set: SetBool,
},
{
name: config.WantVirtualBoxDriverWarning,
set: SetBool,
},
{
name: config.ProfileName,
set: SetString,

View File

@ -305,6 +305,7 @@ func setupViper() {
viper.SetDefault(config.WantUpdateNotification, true)
viper.SetDefault(config.ReminderWaitPeriodInHours, 24)
viper.SetDefault(config.WantNoneDriverWarning, true)
viper.SetDefault(config.WantVirtualBoxDriverWarning, true)
}
func addToPath(dir string) {

View File

@ -38,6 +38,8 @@ const (
ReminderWaitPeriodInHours = "ReminderWaitPeriodInHours"
// WantNoneDriverWarning is the key for WantNoneDriverWarning
WantNoneDriverWarning = "WantNoneDriverWarning"
// WantVirtualBoxDriverWarning is the key for WantVirtualBoxDriverWarning
WantVirtualBoxDriverWarning = "WantVirtualBoxDriverWarning"
// ProfileName represents the key for the global profile parameter
ProfileName = "profile"
// UserFlag is the key for the global user flag (ex. --user=user1)

View File

@ -61,6 +61,7 @@ import (
"k8s.io/minikube/pkg/minikube/out/register"
"k8s.io/minikube/pkg/minikube/proxy"
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/registry"
"k8s.io/minikube/pkg/minikube/style"
"k8s.io/minikube/pkg/minikube/vmpath"
"k8s.io/minikube/pkg/util"
@ -191,6 +192,11 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
go addons.Start(&wg, starter.Cfg, starter.ExistingAddons, addonList)
}
// discourage use of the virtualbox driver
if starter.Cfg.Driver == driver.VirtualBox && viper.GetBool(config.WantVirtualBoxDriverWarning) {
warnVirtualBox()
}
if apiServer {
// special ops for none , like change minikube directory.
// multinode super doesn't work on the none driver
@ -731,3 +737,28 @@ func addCoreDNSEntry(runner command.Runner, name, ip string, cc config.ClusterCo
return nil
}
// prints a warning to the console against the use of the 'virtualbox' driver, if alternatives are available and healthy
func warnVirtualBox() {
var altDriverList strings.Builder
for _, choice := range driver.Choices(true) {
if choice.Name != "virtualbox" && choice.Priority != registry.Discouraged && choice.State.Installed && choice.State.Healthy {
altDriverList.WriteString(fmt.Sprintf("\n\t- %s", choice.Name))
}
}
if altDriverList.Len() != 0 {
out.Boxed(`You have selected "virtualbox" driver, but there are better options !
For better performance and support consider using a different driver: {{.drivers}}
To turn off this warning run:
$ minikube config set WantVirtualBoxDriverWarning false
To learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/
To see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/
`, out.V{"drivers": altDriverList.String()})
}
}

View File

@ -30,6 +30,7 @@ Configurable fields:
* WantBetaUpdateNotification
* ReminderWaitPeriodInHours
* WantNoneDriverWarning
* WantVirtualBoxDriverWarning
* profile
* bootstrapper
* insecure-registry