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.

66 lines
1.9 KiB

  1. ---
  2. - name: reset | Check that kubectl is still here
  3. stat:
  4. path: "{{ bin_dir }}/kubectl"
  5. register: contiv_kubectl
  6. - name: reset | Delete contiv netplugin and netmaster daemonsets
  7. kube:
  8. name: "{{ item }}"
  9. namespace: "kube-system"
  10. kubectl: "{{ bin_dir }}/kubectl"
  11. resource: "ds"
  12. state: absent
  13. with_items:
  14. - contiv-netplugin
  15. - contiv-netmaster
  16. register: contiv_cleanup_deletion
  17. tags:
  18. - network
  19. when:
  20. - contiv_kubectl.stat.exists
  21. - inventory_hostname == groups['kube-master'][0]
  22. - name: reset | Copy contiv temporary cleanup script
  23. copy:
  24. src: ../files/contiv-cleanup.sh # Not in role_path so we must trick...
  25. dest: /opt/cni/bin/cleanup
  26. owner: root
  27. group: root
  28. mode: 0750
  29. when:
  30. - contiv_kubectl.stat.exists
  31. - name: reset | Lay down contiv cleanup template
  32. template:
  33. src: ../templates/contiv-cleanup.yml.j2 # Not in role_path so we must trick...
  34. dest: "{{ kube_config_dir }}/contiv-cleanup.yml" # kube_config_dir is used here as contiv_config_dir is not necessarily set at reset
  35. register: contiv_cleanup_manifest
  36. when:
  37. - contiv_kubectl.stat.exists
  38. - inventory_hostname == groups['kube-master'][0]
  39. - name: reset | Start contiv cleanup resources
  40. kube:
  41. name: "contiv-cleanup"
  42. namespace: "kube-system"
  43. kubectl: "{{ bin_dir }}/kubectl"
  44. resource: "ds"
  45. state: latest
  46. filename: "{{ kube_config_dir }}/contiv-cleanup.yml"
  47. when:
  48. - contiv_kubectl.stat.exists
  49. - inventory_hostname == groups['kube-master'][0]
  50. ignore_errors: true
  51. - name: reset | Wait until contiv cleanup is done
  52. command: "{{ bin_dir }}/kubectl -n kube-system get ds contiv-cleanup -o jsonpath='{.status.numberReady}'"
  53. register: cleanup_done_all_nodes
  54. until: cleanup_done_all_nodes.stdout|int == groups['k8s-cluster']|length
  55. retries: 5
  56. delay: 5
  57. ignore_errors: true
  58. changed_when: false
  59. when:
  60. - contiv_kubectl.stat.exists
  61. - inventory_hostname == groups['kube-master'][0]