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: yurtadm minor version compatibility of kubelet and kubeadm #1244

Merged
Merged
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
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