-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreset-cluster.yml
93 lines (77 loc) · 1.85 KB
/
reset-cluster.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
91
92
93
- name: del local certificate
hosts: localhost
gather_facts: no
tasks:
- name: del local certificate
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/k8s
- /tmp/etcd/certs/
- name: reset kubernetes cluster
hosts: [kube_masters, kube_ingress, kube_workers]
become: yes
become_method: sudo
gather_facts: no
tasks:
- name: Reset Kubernetes cluster
shell: |
kubeadm reset --force
become: true
ignore_errors: true
- name: Purge kubeadm, kubelet, kubectl, and shared packages
apt:
name: "{{ item }}"
state: absent
purge: yes
force: yes
loop:
- kubelet
- kubeadm
- kubectl
- docker-ce
- docker-ce-cli
- containerd.io
- haproxy
- name: reset etcd cluster
hosts: [kube_masters]
become: yes
become_method: sudo
gather_facts: no
vars:
HOST_COUNT: "{{ groups['ingressnodes'] | length }}"
tasks:
- name: stop etcd
systemd:
name: etcd
state: stopped
when: inventory_hostname in groups['kube_masters']
ignore_errors: true
tags: etcd
- name: erase etcd database
file:
path: /var/lib/etcd/
state: absent
when: inventory_hostname in groups['kube_masters']
tags: etcd
- name: Delete etcd
file:
path: "{{ item }}"
state: absent
with_items:
- /usr/local/bin/Documentation/
- /usr/local/bin/etcd
- /usr/local/bin/etcdctl
- /usr/local/bin/README-etcdctl.md
- /usr/local/bin/README.md
- /usr/local/bin/READMEv2-etcdctl.md
when:
- inventory_hostname in groups['kube_masters']
tags: etcd
- name: delete cluster config
file:
path: "{{ item }}"
state: absent
loop:
- /opt/config