Skip to content

Commit 6cdfa09

Browse files
committed
BGP, shard: don't use frr as the default gateway
This PR changes BGP regression to test things using the actual default gateway that exists instead of using the frr router as its default gateway. This does two things: 1) add masquerade routes to github runner for these lanes 2) add routes from github runner back to the nodes for reply traffic since github runner will be the default gateway for the cluster and pod traffic will leave the cluster unSNATed, we have to have the infra setup have these two above pieces for the tests to work properly Signed-off-by: Surya Seetharaman <[email protected]>
1 parent 36e85f4 commit 6cdfa09

File tree

2 files changed

+62
-12
lines changed

2 files changed

+62
-12
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ jobs:
414414
include:
415415
- {"target": "shard-conformance", "ha": "HA", "gateway-mode": "shared", "ipfamily": "ipv4", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-disabled"}
416416
- {"target": "shard-conformance", "ha": "noHA", "gateway-mode": "local", "ipfamily": "dualstack", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-single-node-zones"}
417-
- {"target": "shard-conformance", "ha": "HA", "gateway-mode": "shared", "ipfamily": "ipv4", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-single-node-zones", "routeadvertisements": "advertise-default"}
418-
- {"target": "shard-conformance", "ha": "noHA", "gateway-mode": "local", "ipfamily": "dualstack", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-single-node-zones", "routeadvertisements": "advertise-default"}
417+
- {"target": "shard-conformance", "ha": "HA", "gateway-mode": "shared", "ipfamily": "ipv4", "disable-snat-multiple-gws": "noSnatGW", "second-bridge": "1br", "ic": "ic-single-node-zones", "routeadvertisements": "advertise-default"}
418+
- {"target": "shard-conformance", "ha": "HA", "gateway-mode": "local", "ipfamily": "dualstack", "disable-snat-multiple-gws": "noSnatGW", "second-bridge": "1br", "ic": "ic-single-node-zones", "routeadvertisements": "advertise-default"}
419419
- {"target": "shard-conformance", "ha": "noHA", "gateway-mode": "shared", "ipfamily": "ipv6", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-single-node-zones"}
420420
- {"target": "shard-conformance", "ha": "noHA", "gateway-mode": "shared", "ipfamily": "ipv4", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-single-node-zones"}
421421
- {"target": "control-plane", "ha": "HA", "gateway-mode": "shared", "ipfamily": "ipv6", "disable-snat-multiple-gws": "noSnatGW", "second-bridge": "1br", "ic": "ic-disabled", "dns-name-resolver": "enable-dns-name-resolver"}
@@ -518,6 +518,30 @@ jobs:
518518
echo OVN_TEST_EX_GW_NETWORK=kindexgw >> $GITHUB_ENV
519519
echo OVN_ENABLE_EX_GW_NETWORK_BRIDGE=true >> $GITHUB_ENV
520520
fi
521+
if [[ "$JOB_NAME" == *"shard-conformance"* ]] && [ "$ADVERTISE_DEFAULT_NETWORK" == "true" ]; then
522+
echo "ADVERTISE_DEFAULT_NETWORK=true" >> $GITHUB_ENV
523+
524+
# Use proper variable declaration with default values
525+
NET_CIDR_IPV4=${NET_CIDR_IPV4:-10.244.0.0/16}
526+
NET_CIDR_IPV6=${NET_CIDR_IPV6:-fd00:10:244::/48}
527+
528+
sudo ip a
529+
sudo ip r
530+
531+
# Add masquerade rules for both IPv4 and IPv6 networks
532+
echo "Adding masquerade rule for $NET_CIDR_IPV4"
533+
sudo iptables -t nat -A POSTROUTING -s $NET_CIDR_IPV4 -o eth0 -j MASQUERADE
534+
535+
echo "Adding masquerade rule for $NET_CIDR_IPV6"
536+
sudo ip6tables -t nat -A POSTROUTING -s $NET_CIDR_IPV6 -o eth0 -j MASQUERADE
537+
538+
# Verify the rules were added
539+
echo "IPv4 POSTROUTING rules:"
540+
sudo iptables -t nat -L POSTROUTING -v
541+
542+
echo "IPv6 POSTROUTING rules:"
543+
sudo ip6tables -t nat -L POSTROUTING -v
544+
fi
521545
522546
- name: Disable ufw
523547
# For IPv6 and Dualstack, ufw (Uncomplicated Firewall) should be disabled.

contrib/kind-common

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -679,16 +679,6 @@ deploy_frr_external_container() {
679679
sed -i '/remote-as 64512/a \ neighbor {{ . }} route-reflector-client' frr/frr.conf.tmpl
680680
./demo.sh
681681
popd || exit 1
682-
683-
# this container will act as the gateway for the cluster and will masquerade
684-
# towards the external world
685-
$OCI_BIN exec frr iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
686-
# set default route
687-
FRR_IP=$($OCI_BIN inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" frr)
688-
KIND_NODES=$(kind_get_nodes)
689-
for n in $KIND_NODES; do
690-
$OCI_BIN exec "$n" ip route replace default via "$FRR_IP"
691-
done
692682
}
693683

694684
install_ffr_k8s() {
@@ -708,4 +698,40 @@ install_ffr_k8s() {
708698
popd || exit 1
709699

710700
rm -rf "${FRR_TMP_DIR}"
701+
# Add routes for pod networks dynamically into the github runner for return traffic to pass back
702+
if [ -n "${JOB_NAME:-}" ] && [[ "$JOB_NAME" == *"shard-conformance"* ]] && [ "$ADVERTISE_DEFAULT_NETWORK" == "true" ]; then
703+
echo "Adding routes for Kubernetes pod networks..."
704+
NODES=$(kubectl get nodes -o jsonpath='{.items[*].metadata.name}')
705+
echo "Found nodes: $NODES"
706+
for node in $NODES; do
707+
# Get the addresses
708+
node_ips=$(kubectl get node $node -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
709+
# Get subnet information
710+
subnet_json=$(kubectl get node $node -o jsonpath='{.metadata.annotations.k8s\.ovn\.org/node-subnets}')
711+
712+
if [ "$KIND_IPV4_SUPPORT" == true ]; then
713+
# Extract IPv4 address (first address)
714+
node_ipv4=$(echo "$node_ips" | awk '{print $1}')
715+
ipv4_subnet=$(echo "$subnet_json" | jq -r '.default[0]')
716+
717+
# Add IPv4 route
718+
if [ -n "$ipv4_subnet" ] && [ -n "$node_ipv4" ]; then
719+
echo "Adding IPv4 route for $node ($node_ipv4): $ipv4_subnet"
720+
sudo ip route add $ipv4_subnet via $node_ipv4
721+
fi
722+
fi
723+
724+
# Add IPv6 route if enabled
725+
if [ "$KIND_IPV6_SUPPORT" == true ]; then
726+
# Extract IPv6 address (second address, if present)
727+
node_ipv6=$(echo "$node_ips" | awk '{print $2}')
728+
ipv6_subnet=$(echo "$subnet_json" | jq -r '.default[1] // empty')
729+
730+
if [ -n "$ipv6_subnet" ] && [ -n "$node_ipv6" ]; then
731+
echo "Adding IPv6 route for $node ($node_ipv6): $ipv6_subnet"
732+
sudo ip -6 route add $ipv6_subnet via $node_ipv6
733+
fi
734+
fi
735+
done
736+
fi
711737
}

0 commit comments

Comments
 (0)