From 3d09a18c84ecc2364ac92fbef72bc155df74dfc6 Mon Sep 17 00:00:00 2001 From: Or Shoval Date: Wed, 18 Sep 2024 13:25:06 +0300 Subject: [PATCH 1/2] poc: Use multus default-network to provide ipam claim ref Signed-off-by: Or Shoval --- go-controller/pkg/util/multi_network.go | 9 ++++++--- go-controller/pkg/util/pod_annotation.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go-controller/pkg/util/multi_network.go b/go-controller/pkg/util/multi_network.go index d1e5136a4b..3704cb6920 100644 --- a/go-controller/pkg/util/multi_network.go +++ b/go-controller/pkg/util/multi_network.go @@ -959,9 +959,12 @@ func GetPodNADToNetworkMappingWithActiveNetwork(pod *kapi.Pod, nInfo NetInfo, ac } if nInfo.IsPrimaryNetwork() && AllowsPersistentIPs(nInfo) { - ipamClaimName, wasPersistentIPRequested := pod.Annotations[OvnUDNIPAMClaimName] - if wasPersistentIPRequested { - networkSelections[activeNetworkNADs[0]].IPAMClaimReference = ipamClaimName + network, err := GetK8sPodDefaultNetworkSelection(pod) + if err != nil { + return false, nil, fmt.Errorf("error getting default-network's network-attachment for pod: %w", err) + } + if network != nil { + networkSelections[activeNetworkNADs[0]].IPAMClaimReference = network.IPAMClaimReference } } diff --git a/go-controller/pkg/util/pod_annotation.go b/go-controller/pkg/util/pod_annotation.go index 7fc9e5dec9..33d42867db 100644 --- a/go-controller/pkg/util/pod_annotation.go +++ b/go-controller/pkg/util/pod_annotation.go @@ -53,7 +53,7 @@ const ( DefNetworkAnnotation = "v1.multus-cni.io/default-network" // OvnUDNIPAMClaimName is used for workload owners to instruct OVN-K which // IPAMClaim will hold the allocation for the workload - OvnUDNIPAMClaimName = "k8s.ovn.org/primary-udn-ipamclaim" + //OvnUDNIPAMClaimName = "k8s.ovn.org/primary-udn-ipamclaim" ) var ErrNoPodIPFound = errors.New("no pod IPs found") From be1b6a607c726c33d59a90d8cff6d32730f218ff Mon Sep 17 00:00:00 2001 From: Or Shoval Date: Wed, 18 Sep 2024 16:01:22 +0300 Subject: [PATCH 2/2] DNM: lets run tests Signed-off-by: Or Shoval --- contrib/kind-common | 21 ++++++++++++++++++- go-controller/pkg/util/multi_network_test.go | 22 ++++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/contrib/kind-common b/contrib/kind-common index 5316b1d8ea..7bd7072b13 100644 --- a/contrib/kind-common +++ b/contrib/kind-common @@ -389,7 +389,8 @@ install_cert_manager() { install_kubevirt_ipam_controller() { echo "Installing KubeVirt IPAM controller manager ..." manifest="https://raw.githubusercontent.com/kubevirt/ipam-extensions/main/dist/install.yaml" - run_kubectl apply -f "$manifest" + curl -sL $manifest | sed 's#ghcr.io/kubevirt/ipam-controller#quay.io/oshoval/kubevirt-ipam-controller#' > ipam.yaml + run_kubectl apply -f ipam.yaml kubectl wait -n kubevirt-ipam-controller-system deployment kubevirt-ipam-controller-manager --for condition=Available --timeout 2m } @@ -605,6 +606,24 @@ spec: } ] }' +EOF + + cat <