From 60e58c9c8cf17107c7ba47f974837e453f6631d3 Mon Sep 17 00:00:00 2001 From: cuisongliu Date: Sat, 31 Dec 2022 11:59:24 +0800 Subject: [PATCH] feature(main): fix etcd config (#2323) Signed-off-by: cuisongliu --- pkg/runtime/kubeadm.go | 19 ------------------- pkg/runtime/reset.go | 4 ++++ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/pkg/runtime/kubeadm.go b/pkg/runtime/kubeadm.go index 0fabdb09681..78e2f43d492 100644 --- a/pkg/runtime/kubeadm.go +++ b/pkg/runtime/kubeadm.go @@ -18,7 +18,6 @@ import ( "fmt" "path" "path/filepath" - "strings" "time" "github.com/labring/sealos/pkg/constants" @@ -298,14 +297,6 @@ func (k *KubeadmRuntime) setJoinAdvertiseAddress(advertiseAddress string) { } k.JoinConfiguration.ControlPlane.LocalAPIEndpoint.AdvertiseAddress = advertiseAddress } -func (k *KubeadmRuntime) setDefaultEtcdData(etcdData string) { - if k.ClusterConfiguration.Etcd.Local == nil { - k.ClusterConfiguration.Etcd.Local = &kubeadm.LocalEtcd{} - } - if k.ClusterConfiguration.Etcd.Local.DataDir == "" { - k.ClusterConfiguration.Etcd.Local.DataDir = etcdData - } -} func (k *KubeadmRuntime) cleanJoinLocalAPIEndPoint() { k.JoinConfiguration.ControlPlane = nil @@ -342,14 +333,6 @@ func (k *KubeadmRuntime) getEtcdDataDir() string { return k.ClusterConfiguration.Etcd.Local.DataDir } -func getEtcdEndpointsWithHTTPSPrefix(masters []string) string { - var tmpSlice []string - for _, ip := range masters { - tmpSlice = append(tmpSlice, fmt.Sprintf("https://%s:2379", ip)) - } - return strings.Join(tmpSlice, ",") -} - func (k *KubeadmRuntime) getCRISocket(node string) (string, error) { criSocket, err := k.getRemoteInterface().Socket(node) if err != nil { @@ -377,8 +360,6 @@ func (k *KubeadmRuntime) generateInitConfigs() ([]byte, error) { if k.APIServer.ExtraArgs == nil { k.APIServer.ExtraArgs = make(map[string]string) } - k.APIServer.ExtraArgs["etcd-servers"] = getEtcdEndpointsWithHTTPSPrefix(k.getMasterIPList()) - k.setDefaultEtcdData("/var/lib/etcd") k.IPVS.ExcludeCIDRs = append(k.KubeProxyConfiguration.IPVS.ExcludeCIDRs, fmt.Sprintf("%s/32", k.getVip())) k.IPVS.ExcludeCIDRs = strings2.RemoveDuplicate(k.IPVS.ExcludeCIDRs) diff --git a/pkg/runtime/reset.go b/pkg/runtime/reset.go index 51ec2fc2378..b485916fc81 100644 --- a/pkg/runtime/reset.go +++ b/pkg/runtime/reset.go @@ -73,6 +73,7 @@ func (k *KubeadmRuntime) resetNode(node string) error { resetCmd := fmt.Sprintf(remoteCleanMasterOrNode, vlogToStr(k.vlog), k.getEtcdDataDir()) shim := bootstrap.NewImageShimHelper(k.getSSHInterface(), k.getMaster0IPAndPort()) deleteShimCmd := shim.DeleteCMD(k.getContentData().RootFSPath()) + deleteHomeDirCmd := fmt.Sprintf("rm -rf %s", constants.ClusterDir(k.Cluster.Name)) if err := k.sshCmdAsync(node, resetCmd); err != nil { logger.Error("failed to clean node, exec command %s failed, %v", resetCmd, err) } @@ -89,6 +90,9 @@ func (k *KubeadmRuntime) resetNode(node string) error { if err != nil { logger.Error("exec clean.sh failed %v", err) } + if err := k.sshCmdAsync(node, deleteHomeDirCmd); err != nil { + logger.Error("failed to clean node homedir, exec command %s failed, %v", deleteHomeDirCmd, err) + } err = k.execHostsDelete(node, k.getRegistry().Domain) if err != nil { logger.Error("delete registry hosts failed %v", err)