From 151723e23455689f6796bc4bc30ac5b3e5b9a0c1 Mon Sep 17 00:00:00 2001 From: MatthieuFin Date: Fri, 19 Apr 2024 17:08:37 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20patch=20calico=20node=20t?= =?UTF-8?q?o=20avoid=20vxlan=20tunnel=20drop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if node.projectcalico.org already existe patch node to set asNumber instead of apply resource to prevent remove of existing fields feed by calico-node pods ✅ Closes: 11096 --- .../calico/tasks/peer_with_router.yml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/roles/network_plugin/calico/tasks/peer_with_router.yml b/roles/network_plugin/calico/tasks/peer_with_router.yml index a29ca36ddf9..e2a70aa2aa6 100644 --- a/roles/network_plugin/calico/tasks/peer_with_router.yml +++ b/roles/network_plugin/calico/tasks/peer_with_router.yml @@ -23,6 +23,38 @@ when: - inventory_hostname == groups['kube_control_plane'][0] +- name: Calico | Get node for per node peering + command: + cmd: "{{ bin_dir }}/calicoctl.sh get node {{ inventory_hostname }}" + register: output_get_node + when: + - inventory_hostname in groups['k8s_cluster'] + - local_as is defined + - groups['calico_rr'] | default([]) | length == 0 + delegate_to: "{{ groups['kube_control_plane'][0] }}" + +- name: Calico | Patch node asNumber for per node peering + command: + cmd: |- + {{ bin_dir }}/calicoctl.sh patch node "{{ inventory_hostname }}" --patch '{{ patch is string | ternary(patch, patch | to_json) }}' + vars: + patch: > + {"spec": { + "bgp": { + "asNumber": "{{ local_as }}" + }, + "orchRefs": [{"nodeName": "{{ inventory_hostname }}", "orchestrator": "k8s"}] + }} + register: output + retries: 0 + until: output.rc == 0 + delay: "{{ retry_stagger | random + 3 }}" + when: + - inventory_hostname in groups['k8s_cluster'] + - local_as is defined + - groups['calico_rr'] | default([]) | length == 0 + - output_get_node.rc == 0 + - name: Calico | Configure node asNumber for per node peering command: cmd: "{{ bin_dir }}/calicoctl.sh apply -f -" @@ -48,6 +80,7 @@ - inventory_hostname in groups['k8s_cluster'] - local_as is defined - groups['calico_rr'] | default([]) | length == 0 + - output_get_node.rc != 0 - name: Calico | Configure peering with router(s) at node scope command: