Skip to content

Commit cc91ebf

Browse files
authored
Merge pull request #15003 from kpiljoong/fixes/13487
Fix to prevent accepting addons flag when no kubernetes
2 parents 9583990 + 8cf175f commit cc91ebf

File tree

11 files changed

+32
-5
lines changed

11 files changed

+32
-5
lines changed

cmd/minikube/cmd/config/enable.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"k8s.io/minikube/pkg/addons"
2525
"k8s.io/minikube/pkg/minikube/assets"
2626
"k8s.io/minikube/pkg/minikube/config"
27+
"k8s.io/minikube/pkg/minikube/constants"
2728
"k8s.io/minikube/pkg/minikube/exit"
2829
"k8s.io/minikube/pkg/minikube/out"
2930
"k8s.io/minikube/pkg/minikube/reason"
@@ -39,6 +40,14 @@ var addonsEnableCmd = &cobra.Command{
3940
if len(args) != 1 {
4041
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME")
4142
}
43+
cc, err := config.Load(ClusterFlagValue())
44+
if err != nil && !config.IsNotExist(err) {
45+
out.ErrT(style.Sad, `Unable to load config: {{.error}}`, out.V{"error": err})
46+
}
47+
if cc.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {
48+
exit.Message(reason.Usage, "You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable")
49+
}
50+
4251
addon := args[0]
4352
isDeprecated, replacement, msg := addons.Deprecations(addon)
4453
if isDeprecated && replacement == "" {
@@ -72,7 +81,7 @@ You can view the list of minikube maintainers at: https://github.com/kubernetes/
7281
if registries != "" {
7382
viper.Set(config.AddonRegistries, registries)
7483
}
75-
err := addons.SetAndSave(ClusterFlagValue(), addon, "true")
84+
err = addons.SetAndSave(ClusterFlagValue(), addon, "true")
7685
if err != nil && !errors.Is(err, addons.ErrSkipThisAddon) {
7786
exit.Error(reason.InternalAddonEnable, "enable failed", err)
7887
}

cmd/minikube/cmd/start.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,19 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
309309
validateDockerStorageDriver(driverName)
310310
}
311311

312+
k8sVersion, err := getKubernetesVersion(existing)
313+
if err != nil {
314+
klog.Warningf("failed getting Kubernetes version: %v", err)
315+
}
316+
317+
// Disallow accepting addons flag without Kubernetes
318+
// It places here because cluster config is required to get the old version.
319+
if cmd.Flags().Changed(config.AddonListFlag) {
320+
if k8sVersion == constants.NoKubernetesVersion || viper.GetBool(noKubernetes) {
321+
exit.Message(reason.Usage, "You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable")
322+
}
323+
}
324+
312325
// Download & update the driver, even in --download-only mode
313326
if !viper.GetBool(dryRun) {
314327
updateDriver(driverName)
@@ -320,10 +333,6 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
320333
stopk8s = true
321334
}
322335

323-
k8sVersion, err := getKubernetesVersion(existing)
324-
if err != nil {
325-
klog.Warningf("failed getting Kubernetes version: %v", err)
326-
}
327336
rtime := getContainerRuntime(existing)
328337
cc, n, err := generateClusterConfig(cmd, existing, k8sVersion, rtime, driverName)
329338
if err != nil {

translations/de.json

+1
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@
916916
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "Die Plattengröße eines existierenden Minikube Clusters kann nicht geändert werden. Bitte löschen Sie den Cluster zuerst.",
917917
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "Die Speichergröße eines existierenden Minikube Clusters kann nicht geändert werden. Bitte löschen Sie den Cluster zuerst.",
918918
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
919+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
919920
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
920921
"You have authenticated with a service account that does not have an associated JSON. The GCP Auth requires credentials with a JSON file to in order to continue. The image pull secret has been imported.": "Sie haben sich mit einem Service Account authentifiziert, welcher kein zugehöriges JSON besitzt. GCP Auth benötigt Zugangsdaten in einer JSON-Datei um weitermachen zu können. Das Image Pull Secret wurde importiert.",
921922
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "Sie haben den CNI Treiber deaktiviert, aber die \"{{.name}}\" Container Laufzeitumgebung benötigt ein CNI",

translations/es.json

+1
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@
914914
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
915915
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
916916
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
917+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
917918
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
918919
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
919920
"You have selected \"virtualbox\" driver, but there are better options !\nFor better performance and support consider using a different driver: {{.drivers}}\n\nTo turn off this warning run:\n\n\t$ minikube config set WantVirtualBoxDriverWarning false\n\n\nTo learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/\nTo see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/\n\n": "",

translations/fr.json

+1
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@
894894
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "Vous ne pouvez pas modifier la taille du disque pour un cluster minikube existant. Veuillez d'abord supprimer le cluster.",
895895
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "Vous ne pouvez pas modifier la taille de la mémoire d'un cluster minikube existant. Veuillez d'abord supprimer le cluster.",
896896
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "Vous ne pouvez pas modifier l'adresse IP statique d'un cluster minikube existant. Veuillez d'abord supprimer le cluster.",
897+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
897898
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "Vous vous êtes authentifié avec un compte de service qui n'a pas de fichier JSON associé. Le module complémentaire GCP Auth nécessite des informations d'identification avec un fichier JSON pour continuer.",
898899
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue. The image pull secret has been imported.": "Vous vous êtes authentifié avec un compte de service qui n'a pas de fichier JSON associé. Le module complémentaire GCP Auth nécessite des informations d'identification avec un fichier JSON pour continuer. Le secret d'extraction d'image a été importé.",
899900
"You have authenticated with a service account that does not have an associated JSON. The GCP Auth requires credentials with a JSON file in order to continue. The image pull secret has been imported.": "Vous vous êtes authentifié avec un compte de service qui n'a pas de fichier JSON associé. L'authentification GCP nécessite des informations d'identification avec un fichier JSON pour continuer. Le secret d'extraction d'image a été importé.",

translations/ja.json

+1
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@
857857
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "既存の minikube クラスターに対して、ディスクサイズを変更できません。最初にクラスターを削除してください。",
858858
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "既存の minikube クラスターに対して、メモリサイズを変更できません。最初にクラスターを削除してください。",
859859
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
860+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
860861
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
861862
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue. The image pull secret has been imported.": "関連する JSON ファイルがないサービスアカウントで認証しています。GCP Auth アドオンは、作業を続行するために JSON ファイル付きクレデンシャルを要求します。イメージ取得シークレットがインポートされました。",
862863
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "CNI 無効が選択されましたが、「{{.name}}」コンテナランタイムは CNI が必要です",

translations/ko.json

+1
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@
913913
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
914914
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
915915
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
916+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
916917
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
917918
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
918919
"You have selected \"virtualbox\" driver, but there are better options !\nFor better performance and support consider using a different driver: {{.drivers}}\n\nTo turn off this warning run:\n\n\t$ minikube config set WantVirtualBoxDriverWarning false\n\n\nTo learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/\nTo see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/\n\n": "",

translations/pl.json

+1
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@
925925
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
926926
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
927927
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
928+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
928929
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
929930
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
930931
"You have selected \"virtualbox\" driver, but there are better options !\nFor better performance and support consider using a different driver: {{.drivers}}\n\nTo turn off this warning run:\n\n\t$ minikube config set WantVirtualBoxDriverWarning false\n\n\nTo learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/\nTo see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/\n\n": "",

translations/ru.json

+1
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@
846846
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
847847
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
848848
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
849+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
849850
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
850851
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
851852
"You have selected \"virtualbox\" driver, but there are better options !\nFor better performance and support consider using a different driver: {{.drivers}}\n\nTo turn off this warning run:\n\n\t$ minikube config set WantVirtualBoxDriverWarning false\n\n\nTo learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/\nTo see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/\n\n": "",

translations/strings.txt

+1
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@
846846
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
847847
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
848848
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
849+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
849850
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
850851
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
851852
"You have selected \"virtualbox\" driver, but there are better options !\nFor better performance and support consider using a different driver: {{.drivers}}\n\nTo turn off this warning run:\n\n\t$ minikube config set WantVirtualBoxDriverWarning false\n\n\nTo learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/\nTo see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/\n\n": "",

translations/zh-CN.json

+1
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@
10341034
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
10351035
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
10361036
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
1037+
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
10371038
"You have authenticated with a service account that does not have an associated JSON file. The GCP Auth addon requires credentials with a JSON file in order to continue.": "",
10381039
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
10391040
"You have selected \"virtualbox\" driver, but there are better options !\nFor better performance and support consider using a different driver: {{.drivers}}\n\nTo turn off this warning run:\n\n\t$ minikube config set WantVirtualBoxDriverWarning false\n\n\nTo learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/\nTo see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/\n\n": "",

0 commit comments

Comments
 (0)