Skip to content

Commit

Permalink
UDN: Add managedTap binding support to Kubevirt CR (#3139)
Browse files Browse the repository at this point in the history
Kubevirt introduce new binding for seamless migration.
kubevirt/kubevirt#13024

This PR adds support to it via the Kubevirt CR in addition to Passt support
(under primaryUserDefinedNetworkBinding FG).

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval authored Dec 1, 2024
1 parent c909dc9 commit 0bd61aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 12 additions & 3 deletions controllers/operands/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const (
)

const (
primaryUDNNetworkBindingName = "passt"
primaryUDNNetworkBindingName = "l2bridge"
passtUDNNetworkBindingName = "passt"
// Needs to align with the NAD that will be deployed by CNAO
primaryUDNNetworkBindingNADName = "primary-udn-kubevirt-binding"
primaryUDNNetworkBindingNADNamespace = "default"
Expand Down Expand Up @@ -523,7 +524,8 @@ func getNetworkBindings(
}

sidecarImage, _ := os.LookupEnv(hcoutil.PrimaryUDNImageEnvV)
networkBindings[primaryUDNNetworkBindingName] = primaryUserDefinedNetworkBinding(sidecarImage)
networkBindings[primaryUDNNetworkBindingName] = primaryUserDefinedNetworkBinding()
networkBindings[passtUDNNetworkBindingName] = passtUserDefinedNetworkBinding(sidecarImage)
}
return networkBindings

Expand Down Expand Up @@ -752,7 +754,14 @@ func getKVDevConfig(hc *hcov1beta1.HyperConverged) *kubevirtcorev1.DeveloperConf
return devConf
}

func primaryUserDefinedNetworkBinding(sidecarImage string) kubevirtcorev1.InterfaceBindingPlugin {
func primaryUserDefinedNetworkBinding() kubevirtcorev1.InterfaceBindingPlugin {
return kubevirtcorev1.InterfaceBindingPlugin{
DomainAttachmentType: kubevirtcorev1.ManagedTap,
Migration: &kubevirtcorev1.InterfaceBindingMigration{},
}
}

func passtUserDefinedNetworkBinding(sidecarImage string) kubevirtcorev1.InterfaceBindingPlugin {
const bindingComputeMemoryOverhead = "500Mi"
return kubevirtcorev1.InterfaceBindingPlugin{
NetworkAttachmentDefinition: path.Join(primaryUDNNetworkBindingNADNamespace, primaryUDNNetworkBindingNADName),
Expand Down
5 changes: 3 additions & 2 deletions controllers/operands/kubevirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ Version: 1.2.3`)

Expect(existingResource.Spec.Configuration.NetworkConfiguration).NotTo(BeNil())
Expect(existingResource.Spec.Configuration.NetworkConfiguration.Binding).NotTo(BeNil())
expectedInterfaceBindingPlugin := kubevirtcorev1.InterfaceBindingPlugin{
expectedPasstInterfaceBindingPlugin := kubevirtcorev1.InterfaceBindingPlugin{
NetworkAttachmentDefinition: primaryUDNNetworkBindingNADNamespace + "/" + primaryUDNNetworkBindingNADName,
SidecarImage: expectedPrimaryUDNImage,
Migration: &kubevirtcorev1.InterfaceBindingMigration{
Expand All @@ -2059,7 +2059,8 @@ Version: 1.2.3`)
},
},
}
Expect(existingResource.Spec.Configuration.NetworkConfiguration.Binding[primaryUDNNetworkBindingName]).To(Equal(expectedInterfaceBindingPlugin))
Expect(existingResource.Spec.Configuration.NetworkConfiguration.Binding).To(HaveKeyWithValue(primaryUDNNetworkBindingName, primaryUserDefinedNetworkBinding()))
Expect(existingResource.Spec.Configuration.NetworkConfiguration.Binding).To(HaveKeyWithValue(passtUDNNetworkBindingName, expectedPasstInterfaceBindingPlugin))
})

It("should not add the Primary User Defined Network Binding to Kubevirt CR if PrimaryUserDefinedNetworkBinding is false in HyperConverged CR", func() {
Expand Down

0 comments on commit 0bd61aa

Please sign in to comment.