From c3806f85a4ecbcf676ee09de0e42035c51184ab7 Mon Sep 17 00:00:00 2001 From: 24sama Date: Tue, 24 May 2022 13:34:51 +0800 Subject: [PATCH] doc: add a notice when deploying k8s v1.24 Signed-off-by: 24sama --- pkg/bootstrap/confirm/tasks.go | 28 +++++++++++++++++++++++++++- pkg/bootstrap/precheck/tasks.go | 9 +++++++-- pkg/common/common.go | 15 ++++++++------- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/pkg/bootstrap/confirm/tasks.go b/pkg/bootstrap/confirm/tasks.go index d4bc2f5a..1365bde8 100644 --- a/pkg/bootstrap/confirm/tasks.go +++ b/pkg/bootstrap/confirm/tasks.go @@ -106,6 +106,18 @@ func (i *InstallationConfirm) Execute(runtime connector.Runtime) error { fmt.Println("https://github.com/kubesphere/kubekey#requirements-and-recommendations") fmt.Println("") + if k8sVersion, err := versionutil.ParseGeneric(i.KubeConf.Cluster.Kubernetes.Version); err == nil { + if k8sVersion.AtLeast(versionutil.MustParseSemantic("v1.24.0")) && i.KubeConf.Cluster.Kubernetes.ContainerManager == common.Docker { + fmt.Println("[Notice]") + fmt.Println("Incorrect runtime. Please specify a container runtime other than Docker to install Kubernetes v1.24 or later.") + fmt.Println("For more information, please refer to:") + fmt.Println("https://kubernetes.io/docs/setup/production-environment/container-runtimes/#container-runtimes") + fmt.Println("https://kubernetes.io/blog/2022/02/17/dockershim-faq/") + fmt.Println("") + stopFlag = true + } + } + if stopFlag { os.Exit(1) } @@ -236,8 +248,22 @@ Warning: } fmt.Println() - reader := bufio.NewReader(os.Stdin) + if k8sVersion, err := versionutil.ParseGeneric(u.KubeConf.Cluster.Kubernetes.Version); err == nil { + if cri, ok := u.PipelineCache.GetMustString(common.ClusterNodeCRIRuntimes); ok { + k8sV124 := versionutil.MustParseSemantic("v1.24.0") + if k8sVersion.AtLeast(k8sV124) && versionutil.MustParseSemantic(currentK8sVersion).LessThan(k8sV124) && strings.Contains(cri, "docker") { + fmt.Println("[Notice]") + fmt.Println("Kubernetes v1.24 and later no longer support dockershim and Docker.") + fmt.Println("Please make sure you have completed the migration from Docker to other container runtimes that are compatible with the Kubernetes CRI.") + fmt.Println("For more information, please refer to:") + fmt.Println("https://kubernetes.io/docs/setup/production-environment/container-runtimes/#container-runtimes") + fmt.Println("https://kubernetes.io/blog/2022/02/17/dockershim-faq/") + fmt.Println("") + } + } + } + reader := bufio.NewReader(os.Stdin) confirmOK := false for !confirmOK { fmt.Printf("Continue upgrading cluster? [yes/no]: ") diff --git a/pkg/bootstrap/precheck/tasks.go b/pkg/bootstrap/precheck/tasks.go index 0140c9e2..ce7cc9e7 100644 --- a/pkg/bootstrap/precheck/tasks.go +++ b/pkg/bootstrap/precheck/tasks.go @@ -301,11 +301,16 @@ type GetKubernetesNodesStatus struct { } func (g *GetKubernetesNodesStatus) Execute(runtime connector.Runtime) error { - nodeStatus, err := runtime.GetRunner().SudoCmd("/usr/local/bin/kubectl get node", false) + nodeStatus, err := runtime.GetRunner().SudoCmd("/usr/local/bin/kubectl get node -o wide", false) if err != nil { return err } - g.PipelineCache.Set(common.ClusterNodeStatus, nodeStatus) + + cri, err := runtime.GetRunner().SudoCmd("/usr/local/bin/kubectl get node -o jsonpath=\"{.items[*].status.nodeInfo.containerRuntimeVersion}\"", false) + if err != nil { + return err + } + g.PipelineCache.Set(common.ClusterNodeCRIRuntimes, cri) return nil } diff --git a/pkg/common/common.go b/pkg/common/common.go index 3f0a9b5e..23ac2662 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -68,13 +68,14 @@ const ( // global cache key // PreCheckModule - NodePreCheck = "nodePreCheck" - K8sVersion = "k8sVersion" // current k8s version - KubeSphereVersion = "kubeSphereVersion" // current KubeSphere version - ClusterNodeStatus = "clusterNodeStatus" - DesiredK8sVersion = "desiredK8sVersion" - PlanK8sVersion = "planK8sVersion" - NodeK8sVersion = "NodeK8sVersion" + NodePreCheck = "nodePreCheck" + K8sVersion = "k8sVersion" // current k8s version + KubeSphereVersion = "kubeSphereVersion" // current KubeSphere version + ClusterNodeStatus = "clusterNodeStatus" + ClusterNodeCRIRuntimes = "ClusterNodeCRIRuntimes" + DesiredK8sVersion = "desiredK8sVersion" + PlanK8sVersion = "planK8sVersion" + NodeK8sVersion = "NodeK8sVersion" // ETCDModule ETCDCluster = "etcdCluster"