2017-04-03 13:50:17 +00:00
|
|
|
---
|
2020-08-05 14:56:28 +00:00
|
|
|
- name: "Pre-upgrade | check if kubelet container exists"
|
2019-06-29 21:09:20 +00:00
|
|
|
shell: >-
|
2020-08-05 14:56:28 +00:00
|
|
|
set -o pipefail &&
|
2020-02-07 10:19:43 +00:00
|
|
|
{% if container_manager in ['crio', 'docker'] %}
|
2020-11-28 16:30:47 +00:00
|
|
|
{{ docker_bin_dir }}/docker ps -af name=kubelet | grep kubelet
|
2019-06-29 21:09:20 +00:00
|
|
|
{% elif container_manager == 'containerd' %}
|
2020-11-28 16:30:47 +00:00
|
|
|
{{ bin_dir }}/crictl ps --all --name kubelet | grep kubelet
|
2019-06-29 21:09:20 +00:00
|
|
|
{% endif %}
|
2020-08-05 14:56:28 +00:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2017-11-08 07:40:33 +00:00
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
|
|
|
register: kubelet_container_check
|
|
|
|
|
2017-04-03 13:50:17 +00:00
|
|
|
- name: "Pre-upgrade | copy /var/lib/cni from kubelet"
|
2019-06-29 21:09:20 +00:00
|
|
|
command: >-
|
2020-02-07 10:19:43 +00:00
|
|
|
{% if container_manager in ['crio', 'docker'] %}
|
2019-06-29 21:09:20 +00: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 13:50:17 +00:00
|
|
|
args:
|
|
|
|
creates: "/var/lib/cni"
|
|
|
|
failed_when: false
|
2017-11-08 07:40:33 +00: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 10:33:38 +00:00
|
|
|
when: kubelet_container_check.rc == 0
|
2017-08-21 07:53:49 +00:00
|
|
|
|
2017-11-08 07:40:33 +00:00
|
|
|
- name: "Pre-upgrade | ensure kubelet container is removed if using host deployment"
|
2019-06-29 21:09:20 +00:00
|
|
|
shell: >-
|
2020-02-07 10:19:43 +00:00
|
|
|
{% if container_manager in ['crio', 'docker'] %}
|
2020-11-28 16:30:47 +00:00
|
|
|
{{ docker_bin_dir }}/docker rm -fv kubelet
|
2019-06-29 21:09:20 +00:00
|
|
|
{% elif container_manager == 'containerd' %}
|
2020-11-28 16:30:47 +00:00
|
|
|
{{ bin_dir }}/crictl stop kubelet && {{ bin_dir }}/crictl rm kubelet
|
2019-06-29 21:09:20 +00:00
|
|
|
{% endif %}
|
2017-08-21 07:53:49 +00:00
|
|
|
failed_when: false
|
2017-10-25 20:19:40 +00:00
|
|
|
changed_when: false
|
2017-12-12 18:06:41 +00:00
|
|
|
register: remove_kubelet_container
|
|
|
|
retries: 4
|
|
|
|
until: remove_kubelet_container.rc == 0
|
|
|
|
delay: 5
|
2018-12-06 10:33:38 +00:00
|
|
|
when: kubelet_container_check.rc == 0
|