diff --git a/pkg/cluster-runtime/hook.go b/pkg/cluster-runtime/hook.go index 5dff6dd3846..71abec321ed 100644 --- a/pkg/cluster-runtime/hook.go +++ b/pkg/cluster-runtime/hook.go @@ -112,7 +112,7 @@ func (i *Installer) runHostHook(phase Phase, hosts []net.IP) error { sort.Sort(hookConfigList) for _, hookConfig := range hookConfigList { var targetHosts []net.IP - expectedHosts := i.infraDriver.GetHostIPListByRole(string(hookConfig.Scope)) + expectedHosts := i.getHostIPListByScope(hookConfig.Scope) // Make sure each host got from Scope is in the given host ip list. for _, expected := range expectedHosts { if netUtils.IsInIPList(expected, hosts) { @@ -151,6 +151,24 @@ func (i *Installer) runClusterHook(master0 net.IP, phase Phase) error { return nil } +// getHostIPListByScope get ip list for scope, support use '|' to specify multiple scopes, they are ORed +func (i *Installer) getHostIPListByScope(scope Scope) []net.IP { + var ret []net.IP + scopes := strings.Split(string(scope), "|") + for _, s := range scopes { + hosts := i.infraDriver.GetHostIPListByRole(strings.TrimSpace(s)) + + // remove duplicates + for _, h := range hosts { + if !netUtils.IsInIPList(h, ret) { + ret = append(ret, h) + } + } + } + + return ret +} + func NewShellHook() HookFunc { return func(data string, hosts []net.IP, driver infradriver.InfraDriver) error { rootfs := driver.GetClusterRootfsPath() diff --git a/pkg/runtime/kubernetes/utils.go b/pkg/runtime/kubernetes/utils.go index 780f9535aa2..d2750aa6701 100644 --- a/pkg/runtime/kubernetes/utils.go +++ b/pkg/runtime/kubernetes/utils.go @@ -60,7 +60,7 @@ rm -rf /etc/kubernetes/ && \ rm -rf /etc/systemd/system/kubelet.service.d && rm -rf /etc/systemd/system/kubelet.service && \ rm -rf /usr/bin/kubeadm && rm -rf /usr/bin/kubelet-pre-start.sh && \ rm -rf /usr/bin/kubelet && rm -rf /usr/bin/kubectl && \ -rm -rf /var/lib/kubelet && rm -rf /etc/sysctl.d/k8s.conf && \ +rm -rf /var/lib/kubelet/* && rm -rf /etc/sysctl.d/k8s.conf && \ rm -rf /etc/cni && rm -rf /opt/cni && \ rm -rf /var/lib/etcd && rm -rf /var/etcd `