@@ -11813,6 +11813,228 @@ var _ = ginkgo.Describe("OVN master EgressIP Operations cluster default network"
1181311813 gomega.Expect(err).NotTo(gomega.HaveOccurred())
1181411814 })
1181511815
11816+ ginkgo.It("creates pod to pod and pod to join LRPs for multiple default network subnets of the same IP family", func() {
11817+ // test creates two IPv4 cluster subnets and two IPv6 cluster subnets and ensures the appropriate pod to pod and
11818+ // pod to join LRPs are created.
11819+ app.Action = func(*cli.Context) error {
11820+ config.IPv4Mode = true
11821+ config.IPv6Mode = true
11822+ clusterSubnetIPv41 := ovntest.MustParseIPNet("10.128.0.0/14")
11823+ clusterSubnetIPv42 := ovntest.MustParseIPNet("10.132.0.0/14")
11824+ clusterSubnetIPv61 := ovntest.MustParseIPNet("fd69::1/64")
11825+ clusterSubnetIPv62 := ovntest.MustParseIPNet("fd70::1/64")
11826+ config.Default.ClusterSubnets = []config.CIDRNetworkEntry{
11827+ {
11828+ CIDR: clusterSubnetIPv41,
11829+ HostSubnetLength: 23,
11830+ },
11831+ {
11832+ CIDR: clusterSubnetIPv42,
11833+ HostSubnetLength: 23,
11834+ },
11835+ {
11836+ CIDR: clusterSubnetIPv61,
11837+ HostSubnetLength: 120,
11838+ },
11839+ {
11840+ CIDR: clusterSubnetIPv62,
11841+ HostSubnetLength: 120,
11842+ },
11843+ }
11844+ node1IPv4 := "192.168.126.12"
11845+ node1IPv4CIDR := node1IPv4 + "/24"
11846+ node1IPv6 := "::feff:c0a8:8e0c"
11847+ node1IPv6CIDR := node1IPv6 + "/64"
11848+ egressNamespace := newNamespace(eipNamespace)
11849+ annotations := map[string]string{
11850+ "k8s.ovn.org/node-primary-ifaddr": fmt.Sprintf("{\"ipv4\": \"%s\", \"ipv6\": \"%s\"}", node1IPv4CIDR, node1IPv6CIDR),
11851+ "k8s.ovn.org/node-subnets": "{\"default\":[\"10.128.0.0/23\", \"10.132.0.0/23\", \"fd69::1/120\"]}",
11852+ util.OVNNodeHostCIDRs: fmt.Sprintf("[\"%s\",\"%s\"]", node1IPv4CIDR, node1IPv6CIDR),
11853+ }
11854+ node1 := getNodeObj(node1Name, annotations, nil)
11855+
11856+ node1Switch := &nbdb.LogicalSwitch{
11857+ UUID: node1.Name + "-UUID",
11858+ Name: node1.Name,
11859+ }
11860+
11861+ fakeOvn.startWithDBSetup(
11862+ libovsdbtest.TestSetup{
11863+ NBData: []libovsdbtest.TestData{
11864+ &nbdb.LogicalRouterPort{
11865+ UUID: types.GWRouterToJoinSwitchPrefix + types.GWRouterPrefix + node1.Name + "-UUID",
11866+ Name: types.GWRouterToJoinSwitchPrefix + types.GWRouterPrefix + node1.Name,
11867+ Networks: []string{nodeLogicalRouterIfAddrV4, nodeLogicalRouterIfAddrV6},
11868+ },
11869+ &nbdb.LogicalRouter{
11870+ Name: types.OVNClusterRouter,
11871+ UUID: types.OVNClusterRouter + "-UUID",
11872+ },
11873+ &nbdb.LogicalRouter{
11874+ Name: types.GWRouterPrefix + node1.Name,
11875+ UUID: types.GWRouterPrefix + node1.Name + "-UUID",
11876+ Ports: []string{types.GWRouterToJoinSwitchPrefix + types.GWRouterPrefix + node1.Name + "-UUID"},
11877+ },
11878+ &nbdb.LogicalSwitchPort{
11879+ UUID: types.EXTSwitchToGWRouterPrefix + types.GWRouterPrefix + node1Name + "-UUID",
11880+ Name: types.EXTSwitchToGWRouterPrefix + types.GWRouterPrefix + node1Name,
11881+ Type: "router",
11882+ Options: map[string]string{
11883+ "nat-addresses": "router",
11884+ "exclude-lb-vips-from-garp": "true",
11885+ "router-port": types.GWRouterToExtSwitchPrefix + "GR_" + node1Name,
11886+ },
11887+ },
11888+ &nbdb.LogicalSwitch{
11889+ UUID: types.ExternalSwitchPrefix + node1Name + "-UUID",
11890+ Name: types.ExternalSwitchPrefix + node1Name,
11891+ Ports: []string{types.EXTSwitchToGWRouterPrefix + types.GWRouterPrefix + node1Name + "-UUID"},
11892+ },
11893+ node1Switch,
11894+ },
11895+ },
11896+ &corev1.NodeList{
11897+ Items: []corev1.Node{node1},
11898+ },
11899+ &corev1.NamespaceList{
11900+ Items: []corev1.Namespace{*egressNamespace},
11901+ },
11902+ )
11903+ err := fakeOvn.controller.WatchEgressIPNamespaces()
11904+ gomega.Expect(err).NotTo(gomega.HaveOccurred())
11905+ err = fakeOvn.controller.WatchEgressIPPods()
11906+ gomega.Expect(err).NotTo(gomega.HaveOccurred())
11907+ err = fakeOvn.controller.WatchEgressNodes()
11908+ gomega.Expect(err).NotTo(gomega.HaveOccurred())
11909+ err = fakeOvn.controller.WatchEgressIP()
11910+ gomega.Expect(err).NotTo(gomega.HaveOccurred())
11911+
11912+ egressSVCServedPodsASv4, egressSVCServedPodsASv6 := buildEgressServiceAddressSets(nil)
11913+ egressIPServedPodsASv4, egressIPServedPodsASv6 := buildEgressIPServedPodsAddressSets([]string{}, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName)
11914+ egressNodeIPsASv4, egressNodeIPsASv6 := buildEgressIPNodeAddressSets([]string{node1IPv4, node1IPv6})
11915+
11916+ node1Switch.QOSRules = []string{"default-QoS-UUID", "default-QoSv6-UUID"}
11917+ expectedDatabaseState := []libovsdbtest.TestData{
11918+ getNoReRouteReplyTrafficPolicy(types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName),
11919+ &nbdb.LogicalRouterPolicy{
11920+ Priority: types.DefaultNoRereoutePriority,
11921+ Match: fmt.Sprintf("(ip4.src == $%s || ip4.src == $%s) && ip4.dst == $%s",
11922+ egressIPServedPodsASv4.Name, egressSVCServedPodsASv4.Name, egressNodeIPsASv4.Name),
11923+ Action: nbdb.LogicalRouterPolicyActionAllow,
11924+ UUID: "default-v4-no-reroute-node-UUID",
11925+ Options: map[string]string{"pkt_mark": types.EgressIPNodeConnectionMark},
11926+ ExternalIDs: getEgressIPLRPNoReRoutePodToNodeDbIDs(IPFamilyValueV4, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11927+ },
11928+ &nbdb.LogicalRouterPolicy{
11929+ Priority: types.DefaultNoRereoutePriority,
11930+ Match: fmt.Sprintf("(ip6.src == $%s || ip6.src == $%s) && ip6.dst == $%s",
11931+ egressIPServedPodsASv6.Name, egressSVCServedPodsASv6.Name, egressNodeIPsASv6.Name),
11932+ Action: nbdb.LogicalRouterPolicyActionAllow,
11933+ UUID: "default-v6-no-reroute-node-UUID",
11934+ Options: map[string]string{"pkt_mark": types.EgressIPNodeConnectionMark},
11935+ ExternalIDs: getEgressIPLRPNoReRoutePodToNodeDbIDs(IPFamilyValueV6, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11936+ },
11937+
11938+ &nbdb.LogicalRouterPort{
11939+ UUID: types.GWRouterToJoinSwitchPrefix + types.GWRouterPrefix + node1.Name + "-UUID",
11940+ Name: types.GWRouterToJoinSwitchPrefix + types.GWRouterPrefix + node1.Name,
11941+ Networks: []string{nodeLogicalRouterIfAddrV4, nodeLogicalRouterIfAddrV6},
11942+ },
11943+ &nbdb.LogicalRouterPolicy{
11944+ Priority: types.DefaultNoRereoutePriority,
11945+ Match: "ip4.src == 10.128.0.0/14 && ip4.dst == 10.128.0.0/14",
11946+ Action: nbdb.LogicalRouterPolicyActionAllow,
11947+ UUID: "no-reroute-ipv4-1-UUID",
11948+ ExternalIDs: getEgressIPLRPNoReRoutePodToPodDbIDs(IPFamilyValueV4, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11949+ },
11950+ &nbdb.LogicalRouterPolicy{
11951+ Priority: types.DefaultNoRereoutePriority,
11952+ Match: "ip4.src == 10.132.0.0/14 && ip4.dst == 10.132.0.0/14",
11953+ Action: nbdb.LogicalRouterPolicyActionAllow,
11954+ UUID: "no-reroute-ipv4-2-UUID",
11955+ ExternalIDs: getEgressIPLRPNoReRoutePodToPodDbIDs(IPFamilyValueV4, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11956+ },
11957+ &nbdb.LogicalRouterPolicy{
11958+ Priority: types.DefaultNoRereoutePriority,
11959+ Match: "ip6.src == fd69::1/64 && ip6.dst == fd69::1/64",
11960+ Action: nbdb.LogicalRouterPolicyActionAllow,
11961+ UUID: "no-reroute-ipv6-1-UUID",
11962+ ExternalIDs: getEgressIPLRPNoReRoutePodToPodDbIDs(IPFamilyValueV6, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11963+ },
11964+ &nbdb.LogicalRouterPolicy{
11965+ Priority: types.DefaultNoRereoutePriority,
11966+ Match: "ip6.src == fd70::1/64 && ip6.dst == fd70::1/64",
11967+ Action: nbdb.LogicalRouterPolicyActionAllow,
11968+ UUID: "no-reroute-ipv6-2-UUID",
11969+ ExternalIDs: getEgressIPLRPNoReRoutePodToPodDbIDs(IPFamilyValueV6, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11970+ },
11971+ &nbdb.LogicalRouterPolicy{
11972+ Priority: types.DefaultNoRereoutePriority,
11973+ Match: fmt.Sprintf("ip4.src == 10.128.0.0/14 && ip4.dst == %s", config.Gateway.V4JoinSubnet),
11974+ Action: nbdb.LogicalRouterPolicyActionAllow,
11975+ UUID: "no-reroute-service-ipv4-1-UUID",
11976+ ExternalIDs: getEgressIPLRPNoReRoutePodToJoinDbIDs(IPFamilyValueV4, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11977+ },
11978+ &nbdb.LogicalRouterPolicy{
11979+ Priority: types.DefaultNoRereoutePriority,
11980+ Match: fmt.Sprintf("ip4.src == 10.132.0.0/14 && ip4.dst == %s", config.Gateway.V4JoinSubnet),
11981+ Action: nbdb.LogicalRouterPolicyActionAllow,
11982+ UUID: "no-reroute-service-ipv4-2-UUID",
11983+ ExternalIDs: getEgressIPLRPNoReRoutePodToJoinDbIDs(IPFamilyValueV4, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11984+ },
11985+ &nbdb.LogicalRouterPolicy{
11986+ Priority: types.DefaultNoRereoutePriority,
11987+ Match: fmt.Sprintf("ip6.src == fd69::1/64 && ip6.dst == %s", config.Gateway.V6JoinSubnet),
11988+ Action: nbdb.LogicalRouterPolicyActionAllow,
11989+ UUID: "no-reroute-service-ipv6-1-UUID",
11990+ ExternalIDs: getEgressIPLRPNoReRoutePodToJoinDbIDs(IPFamilyValueV6, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11991+ },
11992+ &nbdb.LogicalRouterPolicy{
11993+ Priority: types.DefaultNoRereoutePriority,
11994+ Match: fmt.Sprintf("ip6.src == fd70::1/64 && ip6.dst == %s", config.Gateway.V6JoinSubnet),
11995+ Action: nbdb.LogicalRouterPolicyActionAllow,
11996+ UUID: "no-reroute-service-ipv6-2-UUID",
11997+ ExternalIDs: getEgressIPLRPNoReRoutePodToJoinDbIDs(IPFamilyValueV6, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName).GetExternalIDs(),
11998+ },
11999+ &nbdb.LogicalRouter{
12000+ Name: types.OVNClusterRouter,
12001+ UUID: types.OVNClusterRouter + "-UUID",
12002+ Policies: []string{"no-reroute-ipv4-1-UUID", "no-reroute-ipv4-2-UUID", "no-reroute-service-ipv4-1-UUID",
12003+ "no-reroute-ipv6-1-UUID", "no-reroute-ipv6-2-UUID", "no-reroute-service-ipv4-2-UUID", "no-reroute-service-ipv6-1-UUID",
12004+ "no-reroute-service-ipv6-2-UUID", "default-v4-no-reroute-node-UUID", "default-v6-no-reroute-node-UUID", "default-no-reroute-reply-traffic"},
12005+ },
12006+ &nbdb.LogicalRouter{
12007+ Name: types.GWRouterPrefix + node1.Name,
12008+ UUID: types.GWRouterPrefix + node1.Name + "-UUID",
12009+ Ports: []string{types.GWRouterToJoinSwitchPrefix + types.GWRouterPrefix + node1.Name + "-UUID"},
12010+ },
12011+ &nbdb.LogicalSwitchPort{
12012+ UUID: types.EXTSwitchToGWRouterPrefix + types.GWRouterPrefix + node1Name + "-UUID",
12013+ Name: types.EXTSwitchToGWRouterPrefix + types.GWRouterPrefix + node1Name,
12014+ Type: "router",
12015+ Options: map[string]string{
12016+ "router-port": types.GWRouterToExtSwitchPrefix + "GR_" + node1Name,
12017+ "nat-addresses": "router",
12018+ "exclude-lb-vips-from-garp": "true",
12019+ },
12020+ },
12021+ &nbdb.LogicalSwitch{
12022+ UUID: types.ExternalSwitchPrefix + node1Name + "-UUID",
12023+ Name: types.ExternalSwitchPrefix + node1Name,
12024+ Ports: []string{types.EXTSwitchToGWRouterPrefix + types.GWRouterPrefix + node1Name + "-UUID"},
12025+ },
12026+ node1Switch,
12027+ getDefaultQoSRule(false, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName),
12028+ getDefaultQoSRule(true, types.DefaultNetworkName, fakeOvn.controller.eIPC.controllerName),
12029+ egressSVCServedPodsASv4, egressSVCServedPodsASv6, egressIPServedPodsASv4, egressIPServedPodsASv6, egressNodeIPsASv4, egressNodeIPsASv6,
12030+ }
12031+ gomega.Eventually(fakeOvn.nbClient).Should(libovsdbtest.HaveData(expectedDatabaseState))
12032+ return nil
12033+ }
12034+ err := app.Run([]string{app.Name})
12035+ gomega.Expect(err).NotTo(gomega.HaveOccurred())
12036+ })
12037+
1181612038 ginkgo.It("should re-balance EgressIPs when their node is removed", func() {
1181712039 app.Action = func(*cli.Context) error {
1181812040 config.IPv4Mode = true
0 commit comments