Skip to content

Commit

Permalink
Merge pull request #1938 from ks-ci-bot/cherry-pick-1934-to-release-3.0
Browse files Browse the repository at this point in the history
[release-3.0] fix: version check error
  • Loading branch information
ks-ci-bot authored Jul 28, 2023
2 parents 14805d8 + 251a641 commit 3e381c6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cmd/kk/pkg/bootstrap/os/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ var (
etcdFiles = []string{
"/usr/local/bin/etcd",
"/etc/ssl/etcd",
"/var/lib/etcd",
"/var/lib/etcd/*",
"/etc/etcd.env",
}
clusterFiles = []string{
Expand All @@ -149,7 +149,7 @@ var (
"/var/log/pods/",
"/var/lib/cni",
"/var/lib/calico",
"/var/lib/kubelet",
"/var/lib/kubelet/*",
"/run/calico",
"/run/flannel",
"/etc/flannel",
Expand Down Expand Up @@ -231,7 +231,7 @@ func (r *RemoveNodeFiles) Execute(runtime connector.Runtime) error {
"/var/log/pods/",
"/var/lib/cni",
"/var/lib/calico",
"/var/lib/kubelet",
"/var/lib/kubelet/*",
"/run/calico",
"/run/flannel",
"/etc/flannel",
Expand Down
4 changes: 3 additions & 1 deletion cmd/kk/pkg/bootstrap/precheck/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,11 @@ func (k *KsVersionCheck) Execute(runtime connector.Runtime) error {
ccKsVersionStr, ccErr := runtime.GetRunner().SudoCmd(
"/usr/local/bin/kubectl get ClusterConfiguration ks-installer -n kubesphere-system -o jsonpath='{.metadata.labels.version}'",
false)
if ccErr == nil && ksVersionStr == "v3.1.0" {

if ccErr == nil && versionutil.MustParseSemantic(ccKsVersionStr).AtLeast(versionutil.MustParseSemantic("v3.1.0")) {
ksVersionStr = ccKsVersionStr
}

k.PipelineCache.Set(common.KubeSphereVersion, ksVersionStr)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kk/pkg/kubernetes/kubernetes_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (k *KubernetesStatus) SearchJoinInfo(runtime connector.Runtime) error {
return nil
}

uploadCertsCmd := "/usr/local/bin/kubeadm init phase upload-certs --upload-certs"
uploadCertsCmd := "/usr/local/bin/kubeadm init phase upload-certs --upload-certs --config /etc/kubernetes/kubeadm-config.yaml"
output, err := runtime.GetRunner().SudoCmd(uploadCertsCmd, true)
if err != nil {
return errors.Wrap(errors.WithStack(err), "Failed to upload kubeadm certs")
Expand Down
15 changes: 15 additions & 0 deletions cmd/kk/pkg/kubernetes/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,23 @@ func (s *SetUpgradePlanModule) Init() {
Action: &SetUpgradePlan{Step: s.Step},
}

generateKubeadmConfigInit := &task.RemoteTask{
Name: "GenerateKubeadmConfig",
Desc: "Generate kubeadm config",
Hosts: s.Runtime.GetHostsByRole(common.Master),
Prepare: &prepare.PrepareCollection{
new(common.OnlyFirstMaster),
},
Action: &GenerateKubeadmConfig{
IsInitConfiguration: true,
WithSecurityEnhancement: s.KubeConf.Arg.SecurityEnhancement,
},
Parallel: true,
}

s.Tasks = []task.Interface{
plan,
generateKubeadmConfigInit,
}
}

Expand Down
11 changes: 11 additions & 0 deletions cmd/kk/pkg/kubernetes/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,12 @@ func (u *UpgradeKubeMaster) Execute(runtime connector.Runtime) error {
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("stop kubelet failed: %s", host.GetName()))
}

if versionutil.MustParseSemantic(u.KubeConf.Cluster.Kubernetes.Version).AtLeast(versionutil.MustParseSemantic("v1.24.0")) {
if _, err := runtime.GetRunner().SudoCmd("sed -i 's/ --network-plugin=cni / /g' /var/lib/kubelet/kubeadm-flags.env", false); err != nil {
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("update kubelet config failed: %s", host.GetName()))
}
}

if err := SetKubeletTasks(runtime, u.KubeAction); err != nil {
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("set kubelet failed: %s", host.GetName()))
}
Expand All @@ -662,6 +668,11 @@ func (u *UpgradeKubeWorker) Execute(runtime connector.Runtime) error {
if _, err := runtime.GetRunner().SudoCmd("systemctl stop kubelet", true); err != nil {
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("stop kubelet failed: %s", host.GetName()))
}
if versionutil.MustParseSemantic(u.KubeConf.Cluster.Kubernetes.Version).AtLeast(versionutil.MustParseSemantic("v1.24.0")) {
if _, err := runtime.GetRunner().SudoCmd("sed -i 's/ --network-plugin=cni / /g' /var/lib/kubelet/kubeadm-flags.env", false); err != nil {
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("update kubelet config failed: %s", host.GetName()))
}
}
if err := SetKubeletTasks(runtime, u.KubeAction); err != nil {
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("set kubelet failed: %s", host.GetName()))
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/kk/pkg/version/kubernetes/version_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
V123
V124
V125
V126
)

var VersionList = []Version{
Expand All @@ -45,6 +46,7 @@ var VersionList = []Version{
V123,
V124,
V125,
V126,
}

func (v Version) String() string {
Expand All @@ -63,6 +65,8 @@ func (v Version) String() string {
return "v1.24"
case V125:
return "v1.25"
case V126:
return "v1.26"
default:
return "invalid option"
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/kk/pkg/version/kubesphere/ks_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,5 @@ var KsV340 = &KsInstaller{
V332.String(),
V331.String(),
V330.String(),
V320.String(),
V321.String(),
},
}

0 comments on commit 3e381c6

Please sign in to comment.