From dfa4f7295fc16974f4f2633e9172c8d6ece73237 Mon Sep 17 00:00:00 2001 From: TrekkieCoder Date: Thu, 8 Feb 2024 17:51:09 +0900 Subject: [PATCH] BFD Implementation - changes for cicd scripts --- cicd/k3s-flannel/bird_config/bird.conf | 20 +++++--- cicd/k3s-flannel/config.sh | 20 +++++--- cicd/k3s-flannel/kube-loxilb.yml | 5 +- cicd/k3s-flannel/llb1_gobgp_config/gobgp.conf | 46 ------------------- cicd/k3s-flannel/llb2_gobgp_config/gobgp.conf | 45 ------------------ cicd/k3s-flannel/rmconfig.sh | 8 +++- 6 files changed, 36 insertions(+), 108 deletions(-) delete mode 100644 cicd/k3s-flannel/llb1_gobgp_config/gobgp.conf delete mode 100644 cicd/k3s-flannel/llb2_gobgp_config/gobgp.conf diff --git a/cicd/k3s-flannel/bird_config/bird.conf b/cicd/k3s-flannel/bird_config/bird.conf index 1d244c989..318c81db1 100644 --- a/cicd/k3s-flannel/bird_config/bird.conf +++ b/cicd/k3s-flannel/bird_config/bird.conf @@ -127,7 +127,7 @@ protocol static { # }; # }; #} - +# # Define simple filter as an example for BGP import filter # See https://gitlab.labs.nic.cz/labs/bird/wikis/BGP_filtering for more examples # filter rt_import @@ -203,22 +203,30 @@ protocol static { # neighbor 10.0.3.1; # } # +filter import_my_routes { + if (net = 0.0.0.0/0) then + { + reject; + } + accept; +} + protocol bgp llb1 { - local as 64512; + local 12.12.12.254 as 64514; neighbor 12.12.12.1 as 64512; ipv4 { - import all; + import filter import_my_routes; export all; }; } protocol bgp llb2 { - local 14.14.14.254 as 64512; - neighbor 14.14.14.1 as 64512; + local 12.12.12.254 as 64514; + neighbor 12.12.12.2 as 64512; ipv4 { - import all; + import filter import_my_routes; export all; }; } diff --git a/cicd/k3s-flannel/config.sh b/cicd/k3s-flannel/config.sh index f7cf30e1c..17be6f4f9 100755 --- a/cicd/k3s-flannel/config.sh +++ b/cicd/k3s-flannel/config.sh @@ -7,8 +7,8 @@ echo "#########################################" echo "Spawning all hosts" echo "#########################################" -spawn_docker_host --dock-type loxilb --dock-name llb1 --with-bgp yes --bgp-config $(pwd)/llb1_gobgp_config --with-ka in -spawn_docker_host --dock-type loxilb --dock-name llb2 --with-bgp yes --bgp-config $(pwd)/llb2_gobgp_config --with-ka in +spawn_docker_host --dock-type loxilb --dock-name llb1 --with-bgp yes --with-ka in +spawn_docker_host --dock-type loxilb --dock-name llb2 --with-bgp yes --with-ka in spawn_docker_host --dock-type host --dock-name ep1 spawn_docker_host --dock-type host --dock-name ep2 spawn_docker_host --dock-type host --dock-name ep3 @@ -37,16 +37,22 @@ sleep 3 sudo ip -n llb1 link set ellb1sys up sudo ip -n llb1 addr add 12.12.12.1/24 dev ellb1sys sudo ip link set esysllb1 up -sudo ip addr add 12.12.12.254/24 dev esysllb1 +#sudo ip addr add 12.12.12.254/24 dev esysllb1 sudo ip link add ellb2sys type veth peer name esysllb2 sleep 3 sudo ip link set ellb2sys netns llb2 sleep 3 sudo ip -n llb2 link set ellb2sys up -sudo ip -n llb2 addr add 14.14.14.1/24 dev ellb2sys +sudo ip -n llb2 addr add 12.12.12.2/24 dev ellb2sys sudo ip link set esysllb2 up -sudo ip addr add 14.14.14.254/24 dev esysllb2 +#sudo ip addr add 14.14.14.254/24 dev esysllb2 + +sudo brctl addbr k3sbr +sudo brctl addif k3sbr esysllb2 +sudo brctl addif k3sbr esysllb1 +sudo ip link set k3sbr up +sudo ip addr add 12.12.12.254/24 dev k3sbr #node1 config config_docker_host --host1 user --host2 r1 --ptype phy --addr 1.1.1.1/24 --gw 1.1.1.254 @@ -99,8 +105,8 @@ $hexec r1 ip route add 20.20.20.1/32 via 11.11.11.11 #add_route llb2 1.1.1.0/24 11.11.11.254 ## host network -sudo ip route add 11.11.11.11/32 via 14.14.14.1 -sudo ip route add 123.123.123.1/32 via 14.14.14.1 +#sudo ip route add 11.11.11.11/32 via 14.14.14.1 +#sudo ip route add 123.123.123.1/32 via 14.14.14.1 sleep 1 ##Create LB rule diff --git a/cicd/k3s-flannel/kube-loxilb.yml b/cicd/k3s-flannel/kube-loxilb.yml index a9284b24f..18c4da508 100644 --- a/cicd/k3s-flannel/kube-loxilb.yml +++ b/cicd/k3s-flannel/kube-loxilb.yml @@ -110,10 +110,11 @@ spec: command: - /bin/kube-loxilb args: - - --loxiURL=http://12.12.12.1:11111,http://14.14.14.1:11111 + - --loxiURL=http://12.12.12.1:11111,http://12.12.12.2:11111 - --externalCIDR=123.123.123.1/24 #- --monitor - #- --setBGP + - --setBGP=64512 + - --extBGPPeers=10.10.10.254:64512,12.12.12.254:64514,11.11.11.254:64511 #- --setLBMode=1 #- --config=/opt/loxilb/agent/kube-loxilb.conf resources: diff --git a/cicd/k3s-flannel/llb1_gobgp_config/gobgp.conf b/cicd/k3s-flannel/llb1_gobgp_config/gobgp.conf deleted file mode 100644 index 53fc72a7e..000000000 --- a/cicd/k3s-flannel/llb1_gobgp_config/gobgp.conf +++ /dev/null @@ -1,46 +0,0 @@ -[global.config] - as = 64512 - router-id = "10.10.10.1" - -[[neighbors]] - [neighbors.config] - neighbor-address = "10.10.10.254" - peer-as = 64512 - -[[neighbors]] - [neighbors.config] - neighbor-address = "12.12.12.254" - peer-as = 64512 - -[[neighbors]] - [neighbors.config] - neighbor-address = "11.11.11.254" - peer-as = 64511 - -[global.apply-policy.config] - export-policy-list = [ "set-next-hop-self", "ext" ] - -[[defined-sets.neighbor-sets]] - neighbor-set-name = "k3s" - neighbor-info-list = [ "12.12.12.254", "10.10.10.254" ] - -[[defined-sets.neighbor-sets]] - neighbor-set-name = "ebgpn" - neighbor-info-list = [ "11.11.11.254" ] - -[[policy-definitions]] - name = "set-next-hop-self" - [[policy-definitions.statements]] - [policy-definitions.statements.conditions.match-neighbor-set] - neighbor-set = "k3s" - [policy-definitions.statements.actions.bgp-actions] - set-next-hop = "12.12.12.1" - set-local-pref = 200 - -[[policy-definitions]] - name = "ext" - [[policy-definitions.statements]] - [policy-definitions.statements.conditions.match-neighbor-set] - neighbor-set = "ebgpn" - [policy-definitions.statements.actions.bgp-actions] - set-next-hop = "11.11.11.11" diff --git a/cicd/k3s-flannel/llb2_gobgp_config/gobgp.conf b/cicd/k3s-flannel/llb2_gobgp_config/gobgp.conf deleted file mode 100644 index 59801e295..000000000 --- a/cicd/k3s-flannel/llb2_gobgp_config/gobgp.conf +++ /dev/null @@ -1,45 +0,0 @@ -[global.config] - as = 64512 - router-id = "10.10.10.2" - -[[neighbors]] - [neighbors.config] - neighbor-address = "10.10.10.254" - peer-as = 64512 - -[[neighbors]] - [neighbors.config] - neighbor-address = "14.14.14.254" - peer-as = 64512 - -[[neighbors]] - [neighbors.config] - neighbor-address = "11.11.11.254" - peer-as = 64511 - -[global.apply-policy.config] - export-policy-list = [ "set-next-hop-self", "ext" ] - -[[defined-sets.neighbor-sets]] - neighbor-set-name = "k3s" - neighbor-info-list = [ "14.14.14.254", "10.10.10.254" ] - -[[defined-sets.neighbor-sets]] - neighbor-set-name = "ebgpn" - neighbor-info-list = [ "11.11.11.254" ] - -[[policy-definitions]] - name = "set-next-hop-self" - [[policy-definitions.statements]] - [policy-definitions.statements.conditions.match-neighbor-set] - neighbor-set = "k3s" - [policy-definitions.statements.actions.bgp-actions] - set-next-hop = "14.14.14.1" - -[[policy-definitions]] - name = "ext" - [[policy-definitions.statements]] - [policy-definitions.statements.conditions.match-neighbor-set] - neighbor-set = "ebgpn" - [policy-definitions.statements.actions.bgp-actions] - set-next-hop = "11.11.11.11" diff --git a/cicd/k3s-flannel/rmconfig.sh b/cicd/k3s-flannel/rmconfig.sh index 0ad725ad6..28021feb5 100755 --- a/cicd/k3s-flannel/rmconfig.sh +++ b/cicd/k3s-flannel/rmconfig.sh @@ -10,8 +10,8 @@ fi source ../common.sh -sudo ip route del 11.11.11.11/32 via 14.14.14.1 -sudo ip route del 123.123.123.1/32 via 14.14.14.1 +#sudo ip route del 11.11.11.11/32 via 14.14.14.1 +#sudo ip route del 123.123.123.1/32 via 14.14.14.1 sudo kubectl $KUBECONFIG delete -f nginx-svc-lb1.yml >> /dev/null 2>&1 sudo kubectl $KUBECONFIG delete -f nginx-svc-lb.yml >> /dev/null 2>&1 @@ -39,6 +39,10 @@ delete_docker_host r2 delete_docker_host ep1 delete_docker_host ep2 delete_docker_host ep3 +sudo brctl delif k3sbr esysllb2 +sudo brctl delif k3sbr esysllb1 +sudo ip link set k3sbr down +sudo brctl delbr k3sbr sudo ip link del esysllb1 sudo ip link del esysllb2