2017-04-03 21:50:17 +08:00
|
|
|
---
|
2020-08-05 22:56:28 +08:00
|
|
|
- name: "Pre-upgrade | check if kubelet container exists"
|
2019-06-30 05:09:20 +08:00
|
|
|
shell: >-
|
2020-08-05 22:56:28 +08:00
|
|
|
set -o pipefail &&
|
2020-02-07 18:19:43 +08:00
|
|
|
{% if container_manager in ['crio', 'docker'] %}
|
2020-11-29 00:30:47 +08:00
|
|
|
{{ docker_bin_dir }}/docker ps -af name=kubelet | grep kubelet
|
2019-06-30 05:09:20 +08:00
|
|
|
{% elif container_manager == 'containerd' %}
|
2020-11-29 00:30:47 +08:00
|
|
|
{{ bin_dir }}/crictl ps --all --name kubelet | grep kubelet
|
2019-06-30 05:09:20 +08:00
|
|
|
{% endif %}
|
2020-08-05 22:56:28 +08:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2017-11-08 15:40:33 +08:00
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
2022-03-03 01:29:14 +08:00
|
|
|
check_mode: no
|
2017-11-08 15:40:33 +08:00
|
|
|
register: kubelet_container_check
|
|
|
|
|
2017-04-03 21:50:17 +08:00
|
|
|
- name: "Pre-upgrade | copy /var/lib/cni from kubelet"
|
2019-06-30 05:09:20 +08:00
|
|
|
command: >-
|
2020-02-07 18:19:43 +08:00
|
|
|
{% if container_manager in ['crio', 'docker'] %}
|
2019-06-30 05:09:20 +08:00
|
|
|
docker cp kubelet:/var/lib/cni /var/lib/cni
|
|
|
|
{% elif container_manager == 'containerd' %}
|
|
|
|
ctr run --rm --mount type=bind,src=/var/lib/cni,dst=/cnilibdir,options=rbind:rw kubelet kubelet-tmp sh -c 'cp /var/lib/cni/* /cnilibdir/'
|
|
|
|
{% endif %}
|
2017-04-03 21:50:17 +08:00
|
|
|
args:
|
|
|
|
creates: "/var/lib/cni"
|
|
|
|
failed_when: false
|
2017-11-08 15:40:33 +08:00
|
|
|
when: kubelet_container_check.rc == 0
|
|
|
|
|
|
|
|
- name: "Pre-upgrade | ensure kubelet container service is stopped if using host deployment"
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: stopped
|
2018-12-06 18:33:38 +08:00
|
|
|
when: kubelet_container_check.rc == 0
|
2017-08-21 15:53:49 +08:00
|
|
|
|
2017-11-08 15:40:33 +08:00
|
|
|
- name: "Pre-upgrade | ensure kubelet container is removed if using host deployment"
|
2019-06-30 05:09:20 +08:00
|
|
|
shell: >-
|
2020-02-07 18:19:43 +08:00
|
|
|
{% if container_manager in ['crio', 'docker'] %}
|
2020-11-29 00:30:47 +08:00
|
|
|
{{ docker_bin_dir }}/docker rm -fv kubelet
|
2019-06-30 05:09:20 +08:00
|
|
|
{% elif container_manager == 'containerd' %}
|
2020-11-29 00:30:47 +08:00
|
|
|
{{ bin_dir }}/crictl stop kubelet && {{ bin_dir }}/crictl rm kubelet
|
2019-06-30 05:09:20 +08:00
|
|
|
{% endif %}
|
2017-08-21 15:53:49 +08:00
|
|
|
failed_when: false
|
2017-10-26 04:19:40 +08:00
|
|
|
changed_when: false
|
2017-12-13 02:06:41 +08:00
|
|
|
register: remove_kubelet_container
|
|
|
|
retries: 4
|
|
|
|
until: remove_kubelet_container.rc == 0
|
|
|
|
delay: 5
|
2018-12-06 18:33:38 +08:00
|
|
|
when: kubelet_container_check.rc == 0
|