stop kubelet first when remove worker node.

This commit is contained in:
hellocn9 2023-06-13 14:40:24 +08:00
parent caeaff8a88
commit abf5b0dc8f
2 changed files with 19 additions and 0 deletions

View File

@ -103,6 +103,15 @@ type ClearNodeOSModule struct {
func (c *ClearNodeOSModule) Init() {
c.Name = "ClearNodeOSModule"
stopKubelet := &task.RemoteTask{
Name: "StopKubelet",
Desc: "Stop Kubelet",
Hosts: c.Runtime.GetHostsByRole(common.Worker),
Prepare: new(DeleteNode),
Action: new(StopKubelet),
Parallel: true,
}
resetNetworkConfig := &task.RemoteTask{
Name: "ResetNetworkConfig",
Desc: "Reset os network config",
@ -131,6 +140,7 @@ func (c *ClearNodeOSModule) Init() {
}
c.Tasks = []task.Interface{
stopKubelet,
resetNetworkConfig,
removeFiles,
daemonReload,

View File

@ -197,6 +197,15 @@ func (r *ResetNetworkConfig) Execute(runtime connector.Runtime) error {
return nil
}
type StopKubelet struct {
common.KubeAction
}
func (s *StopKubelet) Execute(runtime connector.Runtime) error {
_, _ = runtime.GetRunner().SudoCmd("systemctl disable kubelet && systemctl stop kubelet && exit 0", false)
return nil
}
type UninstallETCD struct {
common.KubeAction
}