Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to prevent accepting addons flag when --no-kubernetes #15003

Merged
merged 4 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/minikube/cmd/config/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
Expand All @@ -39,6 +40,14 @@ var addonsEnableCmd = &cobra.Command{
if len(args) != 1 {
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME")
}
cc, err := config.Load(ClusterFlagValue())
if err != nil && !config.IsNotExist(err) {
out.ErrT(style.Sad, `Unable to load config: {{.error}}`, out.V{"error": err})
}
if cc.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {
spowelljr marked this conversation as resolved.
Show resolved Hide resolved
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")
}

addon := args[0]
isDeprecated, replacement, msg := addons.Deprecations(addon)
if isDeprecated && replacement == "" {
Expand Down Expand Up @@ -72,7 +81,7 @@ You can view the list of minikube maintainers at: https://github.com/kubernetes/
if registries != "" {
viper.Set(config.AddonRegistries, registries)
}
err := addons.SetAndSave(ClusterFlagValue(), addon, "true")
err = addons.SetAndSave(ClusterFlagValue(), addon, "true")
if err != nil && !errors.Is(err, addons.ErrSkipThisAddon) {
exit.Error(reason.InternalAddonEnable, "enable failed", err)
}
Expand Down
17 changes: 13 additions & 4 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
validateDockerStorageDriver(driverName)
}

k8sVersion, err := getKubernetesVersion(existing)
if err != nil {
klog.Warningf("failed getting Kubernetes version: %v", err)
}

// Disallow accepting addons flag without Kubernetes
// It places here because cluster config is required to get the old version.
if cmd.Flags().Changed(config.AddonListFlag) {
if k8sVersion == constants.NoKubernetesVersion || viper.GetBool(noKubernetes) {
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")
}
}

// Download & update the driver, even in --download-only mode
if !viper.GetBool(dryRun) {
updateDriver(driverName)
Expand All @@ -320,10 +333,6 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
stopk8s = true
}

k8sVersion, err := getKubernetesVersion(existing)
if err != nil {
klog.Warningf("failed getting Kubernetes version: %v", err)
}
rtime := getContainerRuntime(existing)
cc, n, err := generateClusterConfig(cmd, existing, k8sVersion, rtime, driverName)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@
"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.",
"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.",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"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.",
"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",
Expand Down
1 change: 1 addition & 0 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
"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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@
"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.",
"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.",
"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.",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.",
"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é.",
"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é.",
Expand Down
1 change: 1 addition & 0 deletions translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "既存の minikube クラスターに対して、ディスクサイズを変更できません。最初にクラスターを削除してください。",
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "既存の minikube クラスターに対して、メモリサイズを変更できません。最初にクラスターを削除してください。",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"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 ファイル付きクレデンシャルを要求します。イメージ取得シークレットがインポートされました。",
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "CNI 無効が選択されましたが、「{{.name}}」コンテナランタイムは CNI が必要です",
Expand Down
1 change: 1 addition & 0 deletions translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
"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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
"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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
"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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
"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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@
"You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the memory size for an existing minikube cluster. Please first delete the cluster.": "",
"You cannot change the static IP of an existing minikube cluster. Please first delete the cluster.": "",
"You cannot enable addons on a cluster without Kubernetes, to enable Kubernetes on your cluster, run: minikube start --kubernetes-version=stable": "",
"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.": "",
"You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI": "",
"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": "",
Expand Down