-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.yml
44 lines (39 loc) · 1.07 KB
/
reset.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
---
- name: Check if master setup exists
hosts: kube-master
tasks:
- stat:
path: /etc/kubernetes/admin.conf
register: master_config
- name: Check if helm exists
hosts: kube-master
tasks:
- stat:
path: /usr/local/bin/helm
register: helm_result
- name: Reset Tiller & Helm
hosts: kube-master
tasks:
- command: helm reset
when: helm_result.stat.exists
- file:
path: /usr/local/bin/helm
state: absent
when: helm_result.stat.exists
- name: Drain and delete all nodes in cluster
hosts: kube-master
environment:
KUBECONFIG: "/etc/kubernetes/admin.conf"
tasks:
- command: "kubectl drain {{ item }} --delete-local-data --force --ignore-daemonsets"
with_items: "{{ groups['kube-cluster'] }}"
when: master_config.stat.exists
ignore_errors: true
- command: "kubectl delete node {{ item }}"
with_items: "{{ groups['kube-cluster'] }}"
when: master_config.stat.exists
ignore_errors: true
- name: Reset kubeadm
hosts: kube-cluster
roles:
- { role: reset }