2021-01-19 17:41:00 +08:00
|
|
|
# to clean 'kube_node' nodes
|
2019-06-02 00:04:33 +08:00
|
|
|
- block:
|
2021-01-19 17:41:00 +08:00
|
|
|
- name: stop and disable kube_node service
|
2019-06-02 00:04:33 +08:00
|
|
|
service: name={{ item }} state=stopped enabled=no
|
|
|
|
with_items:
|
2021-04-01 19:18:59 +08:00
|
|
|
- kube-lb
|
2019-06-02 00:04:33 +08:00
|
|
|
- kubelet
|
|
|
|
- kube-proxy
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: umount kubelet filesystems
|
|
|
|
shell: "mount | grep '/var/lib/kubelet'| awk '{print $3}'|xargs umount || exit 0"
|
|
|
|
args:
|
|
|
|
warn: false
|
|
|
|
ignore_errors: true
|
|
|
|
|
2021-01-19 17:41:00 +08:00
|
|
|
- name: remove files and dirs of 'kube_node' nodes
|
2019-06-02 00:04:33 +08:00
|
|
|
file: name={{ item }} state=absent
|
|
|
|
with_items:
|
|
|
|
- "/var/lib/kubelet/"
|
|
|
|
- "/var/lib/kube-proxy/"
|
2021-04-01 19:18:59 +08:00
|
|
|
- "/etc/systemd/system/kube-lb.service"
|
2019-06-02 00:04:33 +08:00
|
|
|
- "/etc/systemd/system/kubelet.service"
|
|
|
|
- "/etc/systemd/system/kube-proxy.service"
|
2021-04-01 19:18:59 +08:00
|
|
|
- "/etc/kube-lb/"
|
2019-06-02 00:04:33 +08:00
|
|
|
- "/etc/kubernetes/"
|
|
|
|
- "/root/.kube/config"
|
2022-10-31 20:15:44 +08:00
|
|
|
ignore_errors: true
|
2019-06-02 00:04:33 +08:00
|
|
|
|
|
|
|
# to clean container runtime and networking
|
|
|
|
- block:
|
|
|
|
- name: to check if container 'kubeasz' is running
|
|
|
|
shell: 'docker ps|grep kubeasz || echo "NOT FOUND"'
|
|
|
|
register: install_info
|
|
|
|
|
2019-06-17 09:34:34 +08:00
|
|
|
- block:
|
|
|
|
- name: stop and disable docker service
|
|
|
|
service:
|
|
|
|
name: docker
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
# as k8s-network-plugins use host-network, '/var/run/docker/netns/default' must be umounted
|
2021-01-07 09:30:50 +08:00
|
|
|
- name: umount docker filesystem-1
|
2019-06-17 09:34:34 +08:00
|
|
|
mount: path=/var/run/docker/netns/default state=unmounted
|
|
|
|
|
2021-01-07 09:30:50 +08:00
|
|
|
- name: umount docker filesystem-2
|
2019-06-17 09:34:34 +08:00
|
|
|
mount: path=/var/lib/docker/overlay state=unmounted
|
|
|
|
|
2021-01-07 09:30:50 +08:00
|
|
|
- name: umount docker filesystem-3
|
|
|
|
shell: "echo /var/lib/docker/overlay2/*/merged|xargs umount || exit 0"
|
|
|
|
args:
|
|
|
|
warn: false
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: umount docker filesystem-4
|
|
|
|
shell: "echo /var/lib/docker/containers/*/mounts/shm|xargs umount || exit 0"
|
|
|
|
args:
|
|
|
|
warn: false
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: umount docker filesystem-5
|
|
|
|
shell: "echo /var/run/docker/netns/*|xargs umount || exit 0"
|
|
|
|
args:
|
|
|
|
warn: false
|
|
|
|
ignore_errors: true
|
|
|
|
|
2019-06-17 09:34:34 +08:00
|
|
|
- name: remove files and dirs
|
|
|
|
file: name={{ item }} state=absent
|
|
|
|
with_items:
|
|
|
|
- "/var/lib/docker/"
|
2021-01-07 09:30:50 +08:00
|
|
|
- "/var/lib/dockershim/"
|
2019-06-17 09:34:34 +08:00
|
|
|
- "/var/run/docker/"
|
|
|
|
- "/etc/docker/"
|
|
|
|
- "/etc/systemd/system/docker.service"
|
|
|
|
- "/etc/systemd/system/docker.service.requires/"
|
|
|
|
- "/etc/systemd/system/docker.service.d/"
|
|
|
|
- "/etc/bash_completion.d/docker"
|
|
|
|
- "/usr/bin/docker"
|
|
|
|
when: "'kubeasz' not in install_info.stdout"
|
2021-01-07 09:30:50 +08:00
|
|
|
ignore_errors: true
|
2019-06-02 00:04:33 +08:00
|
|
|
when: CONTAINER_RUNTIME == 'docker'
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: stop and disable containerd service
|
|
|
|
service:
|
|
|
|
name: containerd
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: umount containerd filesystems
|
|
|
|
shell: "mount | grep 'containerd/io.containerd'| awk '{print $3}'|xargs umount || exit 0"
|
|
|
|
args:
|
|
|
|
warn: false
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: remove files and dirs
|
|
|
|
file: name={{ item }} state=absent
|
|
|
|
with_items:
|
|
|
|
- "/etc/containerd/"
|
|
|
|
- "/etc/crictl.yaml"
|
|
|
|
- "/etc/systemd/system/containerd.service"
|
|
|
|
- "/opt/containerd/"
|
|
|
|
- "/var/lib/containerd/"
|
|
|
|
- "/var/run/containerd/"
|
2021-01-07 09:30:50 +08:00
|
|
|
ignore_errors: true
|
2019-06-02 00:04:33 +08:00
|
|
|
when: CONTAINER_RUNTIME == 'containerd'
|
|
|
|
|
|
|
|
- name: remove files and dirs2
|
|
|
|
file: name={{ item }} state=absent
|
|
|
|
with_items:
|
|
|
|
- "/etc/cni/"
|
|
|
|
- "/run/flannel/"
|
|
|
|
- "/etc/calico/"
|
|
|
|
- "/var/run/calico/"
|
|
|
|
- "/var/lib/calico/"
|
|
|
|
- "/var/log/calico/"
|
|
|
|
- "/etc/cilium/"
|
|
|
|
- "/sys/fs/bpf/tc/"
|
|
|
|
- "/var/lib/cni/"
|
|
|
|
- "/var/lib/kube-router/"
|
|
|
|
- "/opt/kube/kube-ovn/"
|
|
|
|
- "/var/run/openvswitch/"
|
|
|
|
- "/etc/origin/openvswitch/"
|
|
|
|
- "/etc/openvswitch/"
|
|
|
|
- "/var/log/openvswitch/"
|
2021-01-18 10:21:48 +08:00
|
|
|
- "/var/run/ovn/"
|
|
|
|
- "/etc/origin/ovn/"
|
|
|
|
- "/etc/ovn/"
|
|
|
|
- "/var/log/ovn/"
|
2022-06-16 12:37:24 +08:00
|
|
|
ignore_errors: true
|
2019-06-02 00:04:33 +08:00
|
|
|
|
2021-01-19 17:41:00 +08:00
|
|
|
when: "inventory_hostname in groups['kube_master'] or inventory_hostname in groups['kube_node']"
|