c12s-kubespray/roles/network_plugin/calico/handlers/main.yml
Hans Feldt 70bbb3e280
calico: avoid POD restart during initial deploy (#6886)
calico PODs are first started and then in a handler killed and
restarted for no reason, nothing has changed.

By using the existing variable 'calico_cni_config' (only defined when
calico has already started) the restart can be skipped.
2020-11-13 00:02:23 -08:00

33 lines
1.1 KiB
YAML

---
- name: reset_calico_cni
command: /bin/true
when: calico_cni_config is defined
notify:
- delete 10-calico.conflist
- docker | delete calico-node containers
- containerd | delete calico-node containers
- name: delete 10-calico.conflist
file:
path: /etc/cni/net.d/10-calico.conflist
state: absent
- name: docker | delete calico-node containers
shell: "{{ docker_bin_dir }}/docker ps -af name=k8s_POD_calico-node* -q | xargs --no-run-if-empty {{ docker_bin_dir }}/docker rm -f"
register: docker_calico_node_remove
until: docker_calico_node_remove is succeeded
retries: 5
when: container_manager in ["docker"]
- name: containerd | delete calico-node containers
shell: '{{ bin_dir }}/crictl pods --name calico-node-* -q | xargs -I% --no-run-if-empty bash -c "{{ bin_dir }}/crictl stopp % && {{ bin_dir }}/crictl rmp %"'
register: crictl_calico_node_remove
until: crictl_calico_node_remove is succeeded
retries: 5
when: container_manager in ["crio", "containerd"]
- name: Calico | Reload NetworkManager
service:
name: NetworkManager
state: reloaded
when: '"running" in nm_check.stdout'