From 3fb1837002c8273ffe8a83056b64ffb8503263bd Mon Sep 17 00:00:00 2001 From: ricolin Date: Tue, 10 Dec 2024 16:37:54 +0800 Subject: [PATCH] add bgp_sourceip --- molecule/bgp/molecule.yml | 2 ++ roles/kube_vip/defaults/main.yml | 3 +++ roles/kube_vip/templates/kube-vip.yaml.j2 | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/molecule/bgp/molecule.yml b/molecule/bgp/molecule.yml index 24a8b53..ab8a29f 100644 --- a/molecule/bgp/molecule.yml +++ b/molecule/bgp/molecule.yml @@ -35,5 +35,7 @@ provisioner: kube_vip_mode: bgp kube_vip_bgp_routerid: 172.17.0.100 kube_vip_bgp_peeraddress: "{{ ansible_facts['default_ipv4'].address }}" + kube_vip_bgp_sourceip: 172.17.0.100 + kube_vip_bgp_multihop: true verifier: name: ansible diff --git a/roles/kube_vip/defaults/main.yml b/roles/kube_vip/defaults/main.yml index a32db44..fb27fbb 100644 --- a/roles/kube_vip/defaults/main.yml +++ b/roles/kube_vip/defaults/main.yml @@ -43,3 +43,6 @@ kube_vip_mode: arp # password to work with a single BGP Peer, if BGP is enabled # kube_vip_bgp_peerpass: + +# Determines which IP address BGP should peer from +# kube_vip_bgp_sourceip: 192.168.0.2 diff --git a/roles/kube_vip/templates/kube-vip.yaml.j2 b/roles/kube_vip/templates/kube-vip.yaml.j2 index 82b48f0..4eaeded 100644 --- a/roles/kube_vip/templates/kube-vip.yaml.j2 +++ b/roles/kube_vip/templates/kube-vip.yaml.j2 @@ -70,8 +70,12 @@ spec: {% if kube_vip_bgp_peers is defined %} - name: bgp_peers value: "{{ kube_vip_bgp_peers }}" - {% endif %} - {% endif %} +{% endif %} +{% if kube_vip_bgp_sourceip is defined %} + - name: bgp_sourceip + value: "{{ kube_vip_bgp_sourceip }}" +{% endif %} +{% endif %} - name: address value: "{{ kube_vip_address }}" - name: prometheus_server