Skip to content

Commit

Permalink
feature(main): fix etcd config (#2323)
Browse files Browse the repository at this point in the history
Signed-off-by: cuisongliu <cuisongliu@qq.com>
  • Loading branch information
cuisongliu authored Dec 31, 2022
1 parent fd8ae0d commit 60e58c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
19 changes: 0 additions & 19 deletions pkg/runtime/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"fmt"
"path"
"path/filepath"
"strings"
"time"

"github.com/labring/sealos/pkg/constants"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions pkg/runtime/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down

0 comments on commit 60e58c9

Please sign in to comment.