mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
fix: replace the "ClearOSEnvironmentModule" in the "DeleteNodePipeline" with the "ClearNodeOSModule"
Signed-off-by: 24sama <jacksama@foxmail.com>
This commit is contained in:
parent
c9a7f1c19e
commit
c71d214af1
|
|
@ -82,6 +82,47 @@ func (c *ConfigureOSModule) Init() {
|
|||
}
|
||||
}
|
||||
|
||||
type ClearNodeOSModule struct {
|
||||
common.KubeModule
|
||||
}
|
||||
|
||||
func (c *ClearNodeOSModule) Init() {
|
||||
c.Name = "ClearNodeOSModule"
|
||||
|
||||
resetNetworkConfig := &task.RemoteTask{
|
||||
Name: "ResetNetworkConfig",
|
||||
Desc: "Reset os network config",
|
||||
Hosts: c.Runtime.GetHostsByRole(common.Worker),
|
||||
Prepare: new(DeleteNode),
|
||||
Action: new(ResetNetworkConfig),
|
||||
Parallel: true,
|
||||
}
|
||||
|
||||
removeFiles := &task.RemoteTask{
|
||||
Name: "RemoveFiles",
|
||||
Desc: "Remove node files",
|
||||
Hosts: c.Runtime.GetHostsByRole(common.Worker),
|
||||
Prepare: new(DeleteNode),
|
||||
Action: new(RemoveNodeFiles),
|
||||
Parallel: true,
|
||||
}
|
||||
|
||||
daemonReload := &task.RemoteTask{
|
||||
Name: "DaemonReload",
|
||||
Desc: "Systemd daemon reload",
|
||||
Hosts: c.Runtime.GetHostsByRole(common.Worker),
|
||||
Prepare: new(DeleteNode),
|
||||
Action: new(DaemonReload),
|
||||
Parallel: true,
|
||||
}
|
||||
|
||||
c.Tasks = []task.Interface{
|
||||
resetNetworkConfig,
|
||||
removeFiles,
|
||||
daemonReload,
|
||||
}
|
||||
}
|
||||
|
||||
type ClearOSEnvironmentModule struct {
|
||||
common.KubeModule
|
||||
}
|
||||
|
|
@ -93,7 +134,6 @@ func (c *ClearOSEnvironmentModule) Init() {
|
|||
Name: "ResetNetworkConfig",
|
||||
Desc: "Reset os network config",
|
||||
Hosts: c.Runtime.GetHostsByRole(common.K8s),
|
||||
Prepare: new(DeleteNode),
|
||||
Action: new(ResetNetworkConfig),
|
||||
Parallel: true,
|
||||
}
|
||||
|
|
@ -104,7 +144,6 @@ func (c *ClearOSEnvironmentModule) Init() {
|
|||
Hosts: c.Runtime.GetHostsByRole(common.ETCD),
|
||||
Prepare: &prepare.PrepareCollection{
|
||||
new(EtcdTypeIsKubeKey),
|
||||
new(DeleteNode),
|
||||
},
|
||||
Action: new(UninstallETCD),
|
||||
Parallel: true,
|
||||
|
|
@ -114,7 +153,6 @@ func (c *ClearOSEnvironmentModule) Init() {
|
|||
Name: "RemoveFiles",
|
||||
Desc: "Remove cluster files",
|
||||
Hosts: c.Runtime.GetHostsByRole(common.K8s),
|
||||
Prepare: new(DeleteNode),
|
||||
Action: new(RemoveFiles),
|
||||
Parallel: true,
|
||||
}
|
||||
|
|
@ -123,7 +161,6 @@ func (c *ClearOSEnvironmentModule) Init() {
|
|||
Name: "DaemonReload",
|
||||
Desc: "Systemd daemon reload",
|
||||
Hosts: c.Runtime.GetHostsByRole(common.K8s),
|
||||
Prepare: new(DeleteNode),
|
||||
Action: new(DaemonReload),
|
||||
Parallel: true,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,38 @@ func (s *UninstallETCD) Execute(runtime connector.Runtime) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type RemoveNodeFiles struct {
|
||||
common.KubeAction
|
||||
}
|
||||
|
||||
func (r *RemoveNodeFiles) Execute(runtime connector.Runtime) error {
|
||||
nodeFiles := []string{
|
||||
"/etc/kubernetes",
|
||||
"/etc/systemd/system/etcd.service",
|
||||
"/var/log/calico",
|
||||
"/etc/cni",
|
||||
"/var/log/pods/",
|
||||
"/var/lib/cni",
|
||||
"/var/lib/calico",
|
||||
"/var/lib/kubelet",
|
||||
"/run/calico",
|
||||
"/run/flannel",
|
||||
"/etc/flannel",
|
||||
"/etc/systemd/system/kubelet.service",
|
||||
"/etc/systemd/system/kubelet.service.d",
|
||||
"/usr/local/bin/kubelet",
|
||||
"/usr/local/bin/kubeadm",
|
||||
"/usr/bin/kubelet",
|
||||
"/tmp/kubekey",
|
||||
"/etc/kubekey",
|
||||
}
|
||||
|
||||
for _, file := range nodeFiles {
|
||||
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf %s", file), true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type RemoveFiles struct {
|
||||
common.KubeAction
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
versionutil "k8s.io/apimachinery/pkg/util/version"
|
||||
|
||||
"github.com/kubesphere/kubekey/pkg/bootstrap/os"
|
||||
"github.com/kubesphere/kubekey/pkg/certs/templates"
|
||||
"github.com/kubesphere/kubekey/pkg/common"
|
||||
"github.com/kubesphere/kubekey/pkg/core/action"
|
||||
|
|
@ -201,13 +200,10 @@ func (u *UninstallAutoRenewCertsModule) Init() {
|
|||
u.Desc = "UnInstall auto renew control-plane certs"
|
||||
|
||||
uninstall := &task.RemoteTask{
|
||||
Name: "UnInstallAutoRenewCerts",
|
||||
Desc: "UnInstall auto renew control-plane certs",
|
||||
Hosts: u.Runtime.GetHostsByRole(common.Master),
|
||||
Prepare: &prepare.PrepareCollection{
|
||||
new(AutoRenewCertsEnabled),
|
||||
new(os.DeleteNode),
|
||||
},
|
||||
Name: "UnInstallAutoRenewCerts",
|
||||
Desc: "UnInstall auto renew control-plane certs",
|
||||
Hosts: u.Runtime.GetHostsByRole(common.Master),
|
||||
Prepare: new(AutoRenewCertsEnabled),
|
||||
Action: new(UninstallAutoRenewCerts),
|
||||
Parallel: true,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/kubesphere/kubekey/pkg/bootstrap/confirm"
|
||||
"github.com/kubesphere/kubekey/pkg/bootstrap/os"
|
||||
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
|
||||
"github.com/kubesphere/kubekey/pkg/certs"
|
||||
"github.com/kubesphere/kubekey/pkg/common"
|
||||
"github.com/kubesphere/kubekey/pkg/core/module"
|
||||
"github.com/kubesphere/kubekey/pkg/core/pipeline"
|
||||
|
|
@ -33,8 +32,7 @@ func DeleteNodePipeline(runtime *common.KubeRuntime) error {
|
|||
&confirm.DeleteNodeConfirmModule{},
|
||||
&kubernetes.CompareConfigAndClusterInfoModule{},
|
||||
&kubernetes.DeleteKubeNodeModule{},
|
||||
&os.ClearOSEnvironmentModule{},
|
||||
&certs.UninstallAutoRenewCertsModule{},
|
||||
&os.ClearNodeOSModule{},
|
||||
}
|
||||
|
||||
p := pipeline.Pipeline{
|
||||
|
|
|
|||
Loading…
Reference in New Issue