From 661e62aacda6ed8d4925a7ffdb7b224930da9437 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Tue, 27 Apr 2021 13:54:06 -0700 Subject: [PATCH 1/5] warn about performance for certain versions of kubernetes --- cmd/minikube/cmd/start.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 6599e63eeaad..6833ff6ee4fe 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -77,6 +77,15 @@ var ( apiServerNames []string apiServerIPs []net.IP hostRe = regexp.MustCompile(`^[^-][\w\.-]+$`) + slowK8sVersions = map[string]struct{}{ + "1.18.16": {}, + "1.18.17": {}, + "1.19.8": {}, + "1.19.9": {}, + "1.20.3": {}, + "1.20.4": {}, + "1.20.5": {}, + } ) func init() { @@ -394,7 +403,7 @@ func startWithDriver(cmd *cobra.Command, starter node.Starter, existing *config. } func warnAboutMultiNodeCNI() { - out.WarningT("Cluster was created without any CNI, adding node to it might cause broken network.") + out.WarningT("Cluster was created without any CNI, adding a node to it might cause broken networking.") } func updateDriver(driverName string) { @@ -1370,6 +1379,11 @@ func validateKubernetesVersion(old *config.ClusterConfig) { exitIfNotForced(reason.KubernetesTooOld, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } + if _, ok := slowK8sVersions[nvs.String()]; ok { + out.WarningT("The requested version of Kubernetes has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start.") + out.WarningT("For more info, see https://github.com/kubernetes/kubeadm/issues/2395") + } + if old == nil || old.KubernetesConfig.KubernetesVersion == "" { return } From 7afe98b855436c3b0b140914a53ed4d12426aabd Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 28 Apr 2021 08:59:15 -0700 Subject: [PATCH 2/5] add 1.21.0 --- cmd/minikube/cmd/start.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 6833ff6ee4fe..db781fcb455a 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -85,6 +85,7 @@ var ( "1.20.3": {}, "1.20.4": {}, "1.20.5": {}, + "1.21.0": {}, } ) From fb5f275baa1cbceb95475a7369852f19a015bfb1 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 28 Apr 2021 16:01:59 -0700 Subject: [PATCH 3/5] abstract kubernetes issues away --- cmd/minikube/cmd/start.go | 19 +++++-------- pkg/minikube/reason/k8s.go | 51 +++++++++++++++++++++++++++++++++++ pkg/minikube/reason/reason.go | 16 ----------- 3 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 pkg/minikube/reason/k8s.go diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index db781fcb455a..1d008e7c89b0 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -77,16 +77,6 @@ var ( apiServerNames []string apiServerIPs []net.IP hostRe = regexp.MustCompile(`^[^-][\w\.-]+$`) - slowK8sVersions = map[string]struct{}{ - "1.18.16": {}, - "1.18.17": {}, - "1.19.8": {}, - "1.19.9": {}, - "1.20.3": {}, - "1.20.4": {}, - "1.20.5": {}, - "1.21.0": {}, - } ) func init() { @@ -1380,9 +1370,12 @@ func validateKubernetesVersion(old *config.ClusterConfig) { exitIfNotForced(reason.KubernetesTooOld, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } - if _, ok := slowK8sVersions[nvs.String()]; ok { - out.WarningT("The requested version of Kubernetes has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start.") - out.WarningT("For more info, see https://github.com/kubernetes/kubeadm/issues/2395") + // If the version of Kubernetes has a known issue, print a warning out to the screen + if issue := reason.ProblematicK8sVersion(nvs); issue.Suggestion != "" { + out.WarningT(issue.Suggestion, out.V{"version": nvs.String()}) + if issue.URL != "" { + out.WarningT("For more information, see: {{.url}}", out.V{"url": issue.URL}) + } } if old == nil || old.KubernetesConfig.KubernetesVersion == "" { diff --git a/pkg/minikube/reason/k8s.go b/pkg/minikube/reason/k8s.go new file mode 100644 index 000000000000..54cac0b5716f --- /dev/null +++ b/pkg/minikube/reason/k8s.go @@ -0,0 +1,51 @@ +/* +Copyright 2021 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package reason + +import "github.com/blang/semver" + +type K8sIssue struct { + VersionsAffected map[string]struct{} + Suggestion string + URL string +} + +var k8sIssues = []K8sIssue{ + { + VersionsAffected: map[string]struct{}{ + "1.18.16": {}, + "1.18.17": {}, + "1.19.8": {}, + "1.19.9": {}, + "1.20.3": {}, + "1.20.4": {}, + "1.20.5": {}, + "1.21.0": {}, + }, + Suggestion: "Kubernetes {{.version}} has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start.", + URL: "https://github.com/kubernetes/kubeadm/issues/2395", + }, +} + +func ProblematicK8sVersion(v semver.Version) K8sIssue { + for _, issue := range k8sIssues { + if _, ok := issue.VersionsAffected[v.String()]; ok { + return issue + } + } + return K8sIssue{} +} diff --git a/pkg/minikube/reason/reason.go b/pkg/minikube/reason/reason.go index fd5edb095ff1..6b02eb92f629 100644 --- a/pkg/minikube/reason/reason.go +++ b/pkg/minikube/reason/reason.go @@ -14,22 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -/* -Copyright 2020 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the Kind{ID: "License", ExitCode: }); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an Kind{ID: "AS IS", ExitCode: } BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - package reason import ( From 8657b72645f75c3ba0c5185e9a710a9f410f6e4b Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 28 Apr 2021 17:29:28 -0700 Subject: [PATCH 4/5] address comments --- cmd/minikube/cmd/start.go | 4 ++-- pkg/minikube/reason/k8s.go | 38 ++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 1d008e7c89b0..a38e23dfe397 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1371,8 +1371,8 @@ func validateKubernetesVersion(old *config.ClusterConfig) { } // If the version of Kubernetes has a known issue, print a warning out to the screen - if issue := reason.ProblematicK8sVersion(nvs); issue.Suggestion != "" { - out.WarningT(issue.Suggestion, out.V{"version": nvs.String()}) + if issue := reason.ProblematicK8sVersion(nvs); issue.Description != "" { + out.WarningT(issue.Description, out.V{"version": nvs.String()}) if issue.URL != "" { out.WarningT("For more information, see: {{.url}}", out.V{"url": issue.URL}) } diff --git a/pkg/minikube/reason/k8s.go b/pkg/minikube/reason/k8s.go index 54cac0b5716f..05697bc9522a 100644 --- a/pkg/minikube/reason/k8s.go +++ b/pkg/minikube/reason/k8s.go @@ -18,33 +18,39 @@ package reason import "github.com/blang/semver" +// K8sIssue represents a known issue with a particular version of Kubernetes type K8sIssue struct { - VersionsAffected map[string]struct{} - Suggestion string - URL string + // VersionAffected is the list of Kubernetes versions that has a particular issue + VersionsAffected []string + // Description is what will be printed to the user describing the issue + Description string + // URL is a link to an issue or documentation about the issue, optional. + URL string } var k8sIssues = []K8sIssue{ { - VersionsAffected: map[string]struct{}{ - "1.18.16": {}, - "1.18.17": {}, - "1.19.8": {}, - "1.19.9": {}, - "1.20.3": {}, - "1.20.4": {}, - "1.20.5": {}, - "1.21.0": {}, + VersionsAffected: []string{ + "1.18.16", + "1.18.17", + "1.19.8", + "1.19.9", + "1.20.3", + "1.20.4", + "1.20.5", + "1.21.0", }, - Suggestion: "Kubernetes {{.version}} has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start.", - URL: "https://github.com/kubernetes/kubeadm/issues/2395", + Description: "Kubernetes {{.version}} has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start.", + URL: "https://github.com/kubernetes/kubeadm/issues/2395", }, } func ProblematicK8sVersion(v semver.Version) K8sIssue { for _, issue := range k8sIssues { - if _, ok := issue.VersionsAffected[v.String()]; ok { - return issue + for _, va := range issue.VersionsAffected { + if va == v.String() { + return issue + } } } return K8sIssue{} From e27e9a1e1bf80336549e56393b76e8a39cd11bd6 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 3 May 2021 12:25:17 -0700 Subject: [PATCH 5/5] return pointer to k8sissue --- cmd/minikube/cmd/start.go | 2 +- pkg/minikube/reason/k8s.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index a38e23dfe397..52ddb0ea0e1b 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1371,7 +1371,7 @@ func validateKubernetesVersion(old *config.ClusterConfig) { } // If the version of Kubernetes has a known issue, print a warning out to the screen - if issue := reason.ProblematicK8sVersion(nvs); issue.Description != "" { + if issue := reason.ProblematicK8sVersion(nvs); issue != nil { out.WarningT(issue.Description, out.V{"version": nvs.String()}) if issue.URL != "" { out.WarningT("For more information, see: {{.url}}", out.V{"url": issue.URL}) diff --git a/pkg/minikube/reason/k8s.go b/pkg/minikube/reason/k8s.go index 05697bc9522a..72b644b87275 100644 --- a/pkg/minikube/reason/k8s.go +++ b/pkg/minikube/reason/k8s.go @@ -45,13 +45,14 @@ var k8sIssues = []K8sIssue{ }, } -func ProblematicK8sVersion(v semver.Version) K8sIssue { +// ProblematicK8sVersion checks for the supplied Kubernetes version and checks if there's a known issue with it. +func ProblematicK8sVersion(v semver.Version) *K8sIssue { for _, issue := range k8sIssues { for _, va := range issue.VersionsAffected { if va == v.String() { - return issue + return &issue } } } - return K8sIssue{} + return nil }