From 6232dc62511ad66560f0370513ab8225553496f6 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Tue, 28 Aug 2018 21:53:43 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=B8=85=E9=99=A4=E5=8D=95=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/clean_one_node.yml | 48 +++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/tools/clean_one_node.yml b/tools/clean_one_node.yml index 92ec5f6..144fdc6 100644 --- a/tools/clean_one_node.yml +++ b/tools/clean_one_node.yml @@ -36,8 +36,12 @@ # 清理 kube-master 相关 - hosts: NODE_TO_DEL tasks: - - name: stop kube-master service - shell: "systemctl stop kube-apiserver kube-controller-manager kube-scheduler" + - name: stop and disable kube-master service + service: name={{ item }} state=stopped enabled=no + with_items: + - kube-apiserver + - kube-controller-manager + - kube-scheduler ignore_errors: true - name: 清理目录和文件 @@ -56,8 +60,11 @@ ignore_errors: true when: "CLUSTER_NETWORK == 'kube-router'" - - name: stop docker service - shell: "systemctl stop docker" + - name: stop and disable docker service + service: + name: docker + state: stopped + enabled: no ignore_errors: true # 因为calico-kube-controller使用了host网络,相当于使用了docker -net=host,需要 @@ -76,7 +83,11 @@ - "/run/flannel/" - "/etc/calico/" - "/var/run/calico/" + - "/var/lib/calico/" - "/var/log/calico/" + - "/etc/cilium/" + - "/var/run/cilium/" + - "/sys/fs/bpf/tc/" - "/var/lib/cni/" - "/var/lib/docker/" - "/var/lib/kube-router/" @@ -85,6 +96,8 @@ - "/etc/systemd/system/docker.service" - "/etc/systemd/system/docker.service.requires/" - "/opt/kube/kube-system/" + - "/etc/bash_completion.d/docker" + ignore_errors: true - name: 清理 iptables shell: "iptables -F && iptables -X \ @@ -95,12 +108,15 @@ - name: 清理网络 shell: "ip link del docker0; \ ip link del tunl0; \ - ip link del flannel.1; \ - ip link del cni0; \ + ip link del flannel.1; \ + ip link del cni0; \ ip link del mynet0; \ - ip link del kube-bridge; \ + ip link del kube-bridge; \ ip link del dummy0; \ - systemctl restart networking; \ + ip link del kube-ipvs0; \ + ip link del cilium_net; \ + ip link del cilium_vxlan; \ + systemctl restart networking; \ systemctl restart network" ignore_errors: true @@ -112,8 +128,11 @@ # 清理etcd 集群相关 - hosts: NODE_TO_DEL tasks: - - name: stop etcd service - shell: systemctl stop etcd + - name: stop and disable etcd service + service: + name: etcd + state: stopped + enabled: no ignore_errors: true - name: 清理目录和文件 @@ -121,6 +140,7 @@ with_items: - "/var/lib/etcd" - "/etc/etcd/" + - "/backup/k8s" - "/etc/systemd/system/etcd.service" # 清理负载均衡相关 @@ -143,6 +163,14 @@ # 清理其他 - hosts: NODE_TO_DEL tasks: + - name: stop and disable chrony + service: name={{ item }} state=stopped enabled=no + with_items: + - chrony + - chronyd + ignore_errors: true + tags: rm_ntp + - name: 清理证书目录和文件 file: name={{ item }} state=absent with_items: