10.4.3. Attaching a virtual machine to secondary user-defined networks by using the CLI
You can connect a virtual machine (VM) to multiple secondary cluster-scoped user-defined networks (CUDNs) by configuring the interface binding.
Prerequisites
-
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
VirtualMachinemanifest to add the CUDN interface details, as in the following example:apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: example-vm namespace: red spec: template: spec: domain: devices: interfaces: - name: secondary_localnet bridge: {} machine: type: "" resources: requests: memory: 2048M networks: - name: secondary_localnet multus: networkName: <localnet_cudn_name>-
metadata.namespacespecifies the namespace in which the VM is located. This value must match a namespace that is associated with the secondary CUDN. -
spec.template.spec.domain.devices.interfaces.namespecifies the name of the secondary user-defined network interface. -
spec.template.spec.networks.namespecifies the name of the network. This value must match the value of thespec.template.spec.domain.devices.interfaces.namefield. -
spec.template.spec.networks.multus.networkNamespecifies the name of the localnetClusterUserDefinedNetworkobject that you previously created.
-
Apply the
VirtualMachinemanifest by running the following command:$ oc apply -f <filename>.yamlwhere:
<filename>Specifies the name of your
VirtualMachinemanifest YAML file.注記When running OpenShift Virtualization on IBM Z®, be aware that certain network interfaces, such as OSA, RoCE, and HiperSockets, only forward network traffic to devices that are registered with the respective interface. As a result, any traffic that is destined for unregistered devices is not forwarded.