mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
fix: KubeSphere version check error
Signed-off-by: pixiake <guofeng@yunify.com>
This commit is contained in:
parent
3e84255904
commit
d8bd5fa70d
|
|
@ -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{
|
||||
|
|
@ -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",
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -469,8 +469,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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -717,6 +717,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()))
|
||||
}
|
||||
|
|
@ -742,6 +748,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()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ const (
|
|||
V123
|
||||
V124
|
||||
V125
|
||||
V126
|
||||
)
|
||||
|
||||
var VersionList = []Version{
|
||||
|
|
@ -45,6 +46,7 @@ var VersionList = []Version{
|
|||
V123,
|
||||
V124,
|
||||
V125,
|
||||
V126,
|
||||
}
|
||||
|
||||
func (v Version) String() string {
|
||||
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,7 +236,5 @@ var KsV340 = &KsInstaller{
|
|||
V332.String(),
|
||||
V331.String(),
|
||||
V330.String(),
|
||||
V320.String(),
|
||||
V321.String(),
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue