Skip to content

Commit

Permalink
UDN, IPAM: Use v1.multus-cni.io/default-network
Browse files Browse the repository at this point in the history
In order to specify ipam-claim-reference for the primary network,
use v1.multus-cni.io/default-network instead
k8s.ovn.org/primary-udn-ipamclaim.

See kubevirt/ipam-extensions#69

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval committed Sep 22, 2024
1 parent 950ff7a commit 91ae191
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
9 changes: 6 additions & 3 deletions go-controller/pkg/util/multi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
8 changes: 4 additions & 4 deletions go-controller/pkg/util/multi_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,8 @@ func TestGetPodNADToNetworkMappingWithActiveNetwork(t *testing.T) {
AllowPersistentIPs: true,
},
inputPodAnnotations: map[string]string{
nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
OvnUDNIPAMClaimName: "the-one-to-the-left-of-the-pony",
nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
"v1.multus-cni.io/default-network": `[{"namespace":"default","name":"ovn-kubernetes","ipam-claim-reference":"the-one-to-the-left-of-the-pony"}]`,
},
expectedIsAttachmentRequested: true,
expectedNetworkSelectionElements: map[string]*nadv1.NetworkSelectionElement{
Expand Down Expand Up @@ -999,8 +999,8 @@ func TestGetPodNADToNetworkMappingWithActiveNetwork(t *testing.T) {
AllowPersistentIPs: true,
},
inputPodAnnotations: map[string]string{
nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
OvnUDNIPAMClaimName: "the-one-to-the-left-of-the-pony",
nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
"v1.multus-cni.io/default-network": `[{"namespace":"default","name":"ovn-kubernetes","ipam-claim-reference":"the-one-to-the-left-of-the-pony"}]`,
},
expectedIsAttachmentRequested: true,
expectedNetworkSelectionElements: map[string]*nadv1.NetworkSelectionElement{
Expand Down
3 changes: 0 additions & 3 deletions go-controller/pkg/util/pod_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ const (
OvnPodAnnotationName = "k8s.ovn.org/pod-networks"
// DefNetworkAnnotation is the pod annotation for the cluster-wide default network
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"
)

var ErrNoPodIPFound = errors.New("no pod IPs found")
Expand Down

0 comments on commit 91ae191

Please sign in to comment.