Skip to content

Commit

Permalink
Merge pull request #1877 from hellocn9/stopkubelet
Browse files Browse the repository at this point in the history
stop kubelet service first when remove worker node.
  • Loading branch information
ks-ci-bot committed Jun 19, 2023
2 parents 88bffbd + abf5b0d commit 04af403
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/kk/pkg/bootstrap/os/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -131,6 +140,7 @@ func (c *ClearNodeOSModule) Init() {
}

c.Tasks = []task.Interface{
stopKubelet,
resetNetworkConfig,
removeFiles,
daemonReload,
Expand Down
9 changes: 9 additions & 0 deletions cmd/kk/pkg/bootstrap/os/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 04af403

Please sign in to comment.