You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB

  1. ---
  2. - name: "Pre-upgrade | check if kubelet container exists"
  3. shell: >-
  4. set -o pipefail &&
  5. {% if container_manager in ['crio', 'docker'] %}
  6. {{ docker_bin_dir }}/docker ps -af name=kubelet | grep kubelet
  7. {% elif container_manager == 'containerd' %}
  8. {{ bin_dir }}/crictl ps --all --name kubelet | grep kubelet
  9. {% endif %}
  10. args:
  11. executable: /bin/bash
  12. failed_when: false
  13. changed_when: false
  14. check_mode: no
  15. register: kubelet_container_check
  16. - name: "Pre-upgrade | copy /var/lib/cni from kubelet"
  17. command: >-
  18. {% if container_manager in ['crio', 'docker'] %}
  19. docker cp kubelet:/var/lib/cni /var/lib/cni
  20. {% elif container_manager == 'containerd' %}
  21. 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/'
  22. {% endif %}
  23. args:
  24. creates: "/var/lib/cni"
  25. failed_when: false
  26. when: kubelet_container_check.rc == 0
  27. - name: "Pre-upgrade | ensure kubelet container service is stopped if using host deployment"
  28. service:
  29. name: kubelet
  30. state: stopped
  31. when: kubelet_container_check.rc == 0
  32. - name: "Pre-upgrade | ensure kubelet container is removed if using host deployment"
  33. shell: >-
  34. {% if container_manager in ['crio', 'docker'] %}
  35. {{ docker_bin_dir }}/docker rm -fv kubelet
  36. {% elif container_manager == 'containerd' %}
  37. {{ bin_dir }}/crictl stop kubelet && {{ bin_dir }}/crictl rm kubelet
  38. {% endif %}
  39. failed_when: false
  40. changed_when: false
  41. register: remove_kubelet_container
  42. retries: 4
  43. until: remove_kubelet_container.rc == 0
  44. delay: 5
  45. when: kubelet_container_check.rc == 0