From 32a97586a7e836140e6f2da1c660f2d3c4f1656e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:52:52 +0800 Subject: [PATCH] [Backport release-v1.4] fix: yurtadm join can't work when kubernetes version large than v1.27.0 (#1998) * fix yurtadm join can't work when kubernetes version large than v1.27.0 (cherry picked from commit ed743d7711c5ecbf6d2895f357b818208ed0e267) --- pkg/yurtadm/util/kubernetes/kubernetes.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/yurtadm/util/kubernetes/kubernetes.go b/pkg/yurtadm/util/kubernetes/kubernetes.go index 472c89b33d6..c227e5e77f7 100644 --- a/pkg/yurtadm/util/kubernetes/kubernetes.go +++ b/pkg/yurtadm/util/kubernetes/kubernetes.go @@ -396,17 +396,25 @@ func SetKubeadmJoinConfig(data joindata.YurtJoinData) error { "criSocket": nodeReg.CRISocket, "name": nodeReg.Name, } + + v1, err := version.NewVersion(data.KubernetesVersion()) + if err != nil { + return err + } + if nodeReg.CRISocket == constants.DefaultDockerCRISocket { ctx["networkPlugin"] = "cni" } else { - ctx["containerRuntime"] = "remote" + v124alpha, err := version.NewVersion("1.24.0-alpha.0") + if err != nil { + return err + } + if v1.LessThan(v124alpha) { + ctx["containerRuntime"] = "remote" + } ctx["containerRuntimeEndpoint"] = nodeReg.CRISocket } - v1, err := version.NewVersion(data.KubernetesVersion()) - if err != nil { - return err - } v2, err := version.NewVersion("v1.22.0") if err != nil { return err