Skip to content

Commit

Permalink
Merge pull request #4551 from maiqueb/udn-egress-integration
Browse files Browse the repository at this point in the history
UDN egress integration: create logical infra for primary UDNs to egress for layer3 networks
  • Loading branch information
trozet authored Aug 7, 2024
2 parents db78637 + 9352c84 commit 87fdae7
Show file tree
Hide file tree
Showing 35 changed files with 3,458 additions and 679 deletions.
1 change: 1 addition & 0 deletions go-controller/pkg/node/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ func gatewayInitInternal(nodeName, gwIntf, egressGatewayIntf string, gwNextHops
l3GwConfig := util.L3GatewayConfig{
Mode: config.Gateway.Mode,
ChassisID: chassisID,
BridgeID: gatewayBridge.bridgeName,
InterfaceID: gatewayBridge.interfaceID,
MACAddress: gatewayBridge.macAddress,
IPAddresses: gatewayBridge.ips,
Expand Down
44 changes: 22 additions & 22 deletions go-controller/pkg/ovn/admin_network_policy_test.go

Large diffs are not rendered by default.

40 changes: 0 additions & 40 deletions go-controller/pkg/ovn/base_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,46 +223,6 @@ func (bnc *BaseNetworkController) AddConfigDurationRecord(kind, namespace, name
return []ovsdb.Operation{}, func() {}, time.Time{}, nil
}

// createOvnClusterRouter creates the central router for the network
func (bnc *BaseNetworkController) createOvnClusterRouter() (*nbdb.LogicalRouter, error) {
// Create default Control Plane Protection (COPP) entry for routers
defaultCOPPUUID, err := EnsureDefaultCOPP(bnc.nbClient)
if err != nil {
return nil, fmt.Errorf("unable to create router control plane protection: %w", err)
}

// Create a single common distributed router for the cluster.
logicalRouterName := bnc.GetNetworkScopedClusterRouterName()
logicalRouter := nbdb.LogicalRouter{
Name: logicalRouterName,
ExternalIDs: map[string]string{
"k8s-cluster-router": "yes",
},
Options: map[string]string{
"always_learn_from_arp_request": "false",
},
Copp: &defaultCOPPUUID,
}
if bnc.IsSecondary() {
logicalRouter.ExternalIDs[types.NetworkExternalID] = bnc.GetNetworkName()
logicalRouter.ExternalIDs[types.TopologyExternalID] = bnc.TopologyType()
}
if bnc.multicastSupport {
logicalRouter.Options = map[string]string{
"mcast_relay": "true",
}
}

err = libovsdbops.CreateOrUpdateLogicalRouter(bnc.nbClient, &logicalRouter, &logicalRouter.Options,
&logicalRouter.ExternalIDs, &logicalRouter.Copp)
if err != nil {
return nil, fmt.Errorf("failed to create distributed router %s, error: %v",
logicalRouterName, err)
}

return &logicalRouter, nil
}

// getOVNClusterRouterPortToJoinSwitchIPs returns the IP addresses for the
// logical router port "GwRouterToJoinSwitchPrefix + OVNClusterRouter" from the
// config.Gateway.V4JoinSubnet and config.Gateway.V6JoinSubnet. This will
Expand Down
11 changes: 6 additions & 5 deletions go-controller/pkg/ovn/base_network_controller_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
ipallocator "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/allocator/ip"
subnetipallocator "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/allocator/ip/subnet"
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config"
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/factory"
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/kubevirt"
logicalswitchmanager "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/logical_switch_manager"
ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types"
Expand Down Expand Up @@ -283,8 +284,8 @@ func (bnc *BaseNetworkController) deletePodLogicalPort(pod *kapi.Pod, portInfo *
// findPodWithIPAddresses finds any pods with the same IPs in a running state on the cluster
// If nodeName is provided, pods only belonging to the same node will be checked, unless this pod has
// potentially live migrated.
func (bnc *BaseNetworkController) findPodWithIPAddresses(needleIPs []net.IP, nodeName string) (*kapi.Pod, error) {
allPods, err := bnc.watchFactory.GetAllPods()
func findPodWithIPAddresses(watchFactory *factory.WatchFactory, netInfo util.NetInfo, needleIPs []net.IP, nodeName string) (*kapi.Pod, error) {
allPods, err := watchFactory.GetAllPods()
if err != nil {
return nil, fmt.Errorf("unable to get pods: %w", err)
}
Expand All @@ -300,12 +301,12 @@ func (bnc *BaseNetworkController) findPodWithIPAddresses(needleIPs []net.IP, nod
// This specifically speeds up a case where a pod may have been annotated by ovnkube-controller, but has not yet
// returned from CNI ADD. In that case the GetPodIPsOfNetwork would unmarshal the annotation and take a perf
// hit for no reason (since the IP cannot be in the same subnet as what we are looking for).
if bnc.TopologyType() == ovntypes.Layer3Topology && !kubevirt.IsPodLiveMigratable(p) && len(nodeName) > 0 && nodeName != p.Spec.NodeName {
if netInfo.TopologyType() == ovntypes.Layer3Topology && !kubevirt.IsPodLiveMigratable(p) && len(nodeName) > 0 && nodeName != p.Spec.NodeName {
continue
}

// check if the pod addresses match in the OVN annotation
haystackPodAddrs, err := util.GetPodIPsOfNetwork(p, bnc.NetInfo)
haystackPodAddrs, err := util.GetPodIPsOfNetwork(p, netInfo)
if err != nil {
continue
}
Expand All @@ -329,7 +330,7 @@ func (bnc *BaseNetworkController) canReleasePodIPs(podIfAddrs []*net.IPNet, node
needleIPs = append(needleIPs, podIPNet.IP)
}

collidingPod, err := bnc.findPodWithIPAddresses(needleIPs, nodeName)
collidingPod, err := findPodWithIPAddresses(bnc.watchFactory, bnc.NetInfo, needleIPs, nodeName)
if err != nil {
return false, fmt.Errorf("unable to determine if pod IPs: %#v are in use by another pod :%w", podIfAddrs, err)

Expand Down
Loading

0 comments on commit 87fdae7

Please sign in to comment.