This repository has been archived by the owner on Oct 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
95.clean.yml
90 lines (77 loc) · 2.34 KB
/
95.clean.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
- hosts:
- kube-node
- deploy
tasks:
- name: stop kube-node service
shell: "systemctl stop kubelet kube-proxy docker"
ignore_errors: true
- name: umount kubelet 挂载的目录
shell: "mount | grep '/var/lib/kubelet'| awk '{print $3}'|xargs umount"
ignore_errors: true
- name: 清理目录和文件
file: name={{ item }} state=absent
with_items:
- "/var/lib/kubelet/"
- "/var/lib/docker/"
- "/var/run/docker/"
- "/etc/kubernetes/"
- "/etc/systemd/system/kubelet.service"
- "/etc/systemd/system/docker.service"
- "/etc/systemd/system/docker.service.requires/"
# - "/root/local/bin/"
- name: 清理 iptables
shell: iptables -F && iptables -X && iptables -F -t nat && iptables -X -t nat
- hosts: kube-master
tasks:
- name: stop kube-master service
shell: "systemctl stop kube-apiserver kube-controller-manager kube-scheduler"
ignore_errors: true
- name: 清理目录和文件
file: name={{ item }} state=absent
with_items:
- "/var/run/kubernetes"
- "/etc/systemd/system/kube-apiserver.service"
- "/etc/systemd/system/kube-controller-manager.service"
- "/etc/systemd/system/kube-scheduler.service"
- "/etc/kubernetes/"
- hosts:
- kube-cluster
- deploy
tasks:
- name: stop flannel service
shell: "systemctl stop flanneld"
ignore_errors: true
- name: 清理网络
shell: "ip link del docker0; systemctl restart networking; ip link del flannel.1"
ignore_errors: true
- name: 清理目录和文件
file: name={{ item }} state=absent
with_items:
- "/var/run/flannel/"
- "/etc/systemd/system/flanneld.service"
- "/root/.kube/"
- hosts: etcd
tasks:
- name: stop etcd service
shell: systemctl stop etcd
ignore_errors: true
- name: 清理目录和文件
file: name={{ item }} state=absent
with_items:
- "/var/lib/etcd"
- "/etc/etcd/"
- "/etc/systemd/system/etcd.service"
- hosts: lb
tasks:
- name: stop keepalived service
shell: systemctl disable keepalived && systemctl stop keepalived
ignore_errors: true
- name: stop haproxy service
shell: systemctl disable haproxy && systemctl stop haproxy
ignore_errors: true
- name: 清理LB 配置文件目录
file: name={{ item }} state=absent
with_items:
- "/etc/haproxy"
- "/etc/keepalived"
ignore_errors: true