-
Notifications
You must be signed in to change notification settings - Fork 0
/
un-kubernetes.yml
69 lines (69 loc) · 2.14 KB
/
un-kubernetes.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
# Remove kubernetes from bare metal hosts
---
- name: Remove Kubernetes and CRI-O from bare-metal hosts
hosts: servers
become: true
gather_facts: true
tasks:
- name: Get installed packages
ansible.builtin.package_facts:
manager: auto
- name: Uninstall cilium # noqa ignore-errors
kubernetes.core.helm:
release_name: cilium
release_namespace: kube-system
state: absent
force: true
wait: true
delegate_to: 127.0.0.1
become: false
run_once: true
ignore_errors: true
- name: Reset kubeadm # noqa no-changed-when
ansible.builtin.command: kubeadm reset --force
when: "'kubeadm' in ansible_facts.packages"
- name: Disable kubelet unit
ansible.builtin.systemd:
name: kubelet
enabled: false
state: stopped
daemon_reload: true
when: "'kubelet' in ansible_facts.packages"
- name: Remove all pods # noqa ignore-errors
ansible.builtin.command: crictl rmp --all --force # noqa no-changed-when
ignore_errors: true
when: "'cri-tools' in ansible_facts.packages"
- name: Remove all containers # noqa ignore-errors
ansible.builtin.command: crictl rm --all # noqa no-changed-when
ignore_errors: true
when: "'cri-tools' in ansible_facts.packages"
- name: Remove all images # noqa ignore-errors
ansible.builtin.command: crictl rmi --all # noqa no-changed-when
ignore_errors: true
when: "'cri-tools' in ansible_facts.packages"
- name: Disable CRI-O
ansible.builtin.systemd:
name: crio
enabled: false
state: stopped
daemon_reload: true
when: "'cri-o' in ansible_facts.packages"
- name: Uninstall kubernetes and CRI-O packages
ansible.builtin.package:
name:
- cri-tools
- kubectl
- kubelet
- kubeadm
- cri-o
- cri-o-runc
state: absent
- name: Clean-up directories
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /etc/kubernetes
- /etc/cni
- /etc/crio
- /var/tmp/kubeadm