Skip to content

Commit

Permalink
Fix: yurtadm minor version compatibility of kubelet and kubeadm (#1244)
Browse files Browse the repository at this point in the history
Signed-off-by: HIHIA <[email protected]>
  • Loading branch information
YTGhost authored Feb 20, 2023
1 parent 9462311 commit 158d140
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions pkg/yurtadm/util/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,17 @@ func CheckAndInstallKubelet(kubernetesResourceServer, clusterVersion string) err
kubeletVersion := strings.Split(string(b), " ")[1]
kubeletVersion = strings.TrimSpace(kubeletVersion)
klog.Infof("kubelet --version: %s", kubeletVersion)
if strings.Contains(string(b), clusterVersion) {
v1, err := version.NewVersion(kubeletVersion)
if err != nil {
return err
}
v2, err := version.NewVersion(clusterVersion)
if err != nil {
return err
}
s1 := v1.Segments()
s2 := v2.Segments()
if s1[0] == s2[0] && s1[1] == s2[1] {
klog.Infof("Kubelet %s already exist, skip install.", clusterVersion)
kubeletExist = true
} else {
Expand Down Expand Up @@ -202,7 +212,17 @@ func CheckAndInstallKubeadm(kubernetesResourceServer, clusterVersion string) err
return fmt.Errorf("can't get the existing kubeadm version: %w", err)
}
kubeadmVersion := info.ClientVersion.GitVersion
if kubeadmVersion == clusterVersion {
v1, err := version.NewVersion(kubeadmVersion)
if err != nil {
return err
}
v2, err := version.NewVersion(clusterVersion)
if err != nil {
return err
}
s1 := v1.Segments()
s2 := v2.Segments()
if s1[0] == s2[0] && s1[1] == s2[1] {
klog.Infof("Kubeadm %s already exist, skip install.", clusterVersion)
kubeadmExist = true
} else {
Expand Down

0 comments on commit 158d140

Please sign in to comment.