From ce9f7891fa71399beb0f0ee71f9c5219313c307b Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 7 Dec 2022 00:12:15 +1300 Subject: [PATCH] add calico bgp configuration --- ansible/roles/k8s_network/tasks/main.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ansible/roles/k8s_network/tasks/main.yaml b/ansible/roles/k8s_network/tasks/main.yaml index 11461fc..a35e9c8 100644 --- a/ansible/roles/k8s_network/tasks/main.yaml +++ b/ansible/roles/k8s_network/tasks/main.yaml @@ -108,6 +108,18 @@ peerIP: "{{ k8s_network_bgp_v6_peer_address }}" asNumber: "{{ k8s_network_bgp_peer_as }}" +- name: add bgp configuration + ansible.builtin.set_fact: + calico_bgp_configuration: + apiVersion: projectcalico.org/v3 + kind: BGPConfiguration + metadata: + name: default + spec: + serviceClusterIPs: + - cidr: "{{ k8s_v4_service_cidr }}" + - cidr: "{{ k8s_v6_service_cidr }}" + - name: write out calico namespace crd ansible.builtin.copy: content: "{{ calico_namespace | to_yaml }}" # Ansible registers the original fact name (with new vaule) inside the updated fact, hence the sub element @@ -142,6 +154,11 @@ content: "{{ calico_bgp_v6_peer | to_nice_yaml }}" dest: "{{ ansible_search_path[0] }}/files/calico/calico_bgp_v6_peer.yaml" +- name: write out calico bgp configuration definition + ansible.builtin.copy: + content: "{{ calico_bgp_configuration | to_nice_yaml }}" + dest: "{{ ansible_search_path[0] }}/files/calico/calico_bgp_configuration.yaml" + - name: install calico definitions to cluster # The order here matters. namespace > config map > operator > installation kubernetes.core.k8s: state: present @@ -154,3 +171,4 @@ - "{{ ansible_search_path[0] }}/files/calico/calico_apiserver.yaml" - "{{ ansible_search_path[0] }}/files/calico/calico_bgp_v4_peer.yaml" - "{{ ansible_search_path[0] }}/files/calico/calico_bgp_v6_peer.yaml" + - "{{ ansible_search_path[0] }}/files/calico/calico_bgp_configuration.yaml"