10.10.3. Attaching a virtual machine to an OVN-Kubernetes secondary network using the CLI
You can connect a virtual machine (VM) to the OVN-Kubernetes secondary network by including the network details in the VM configuration.
Prerequisites
-
You have access to the cluster as a user with
cluster-adminprivileges. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
VirtualMachinemanifest to add the OVN-Kubernetes secondary network interface details, as in the following example:apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: vm-server spec: runStrategy: Always template: spec: domain: devices: interfaces: - name: secondary bridge: {} resources: requests: memory: 1024Mi networks: - name: secondary multus: networkName: <nad_name> nodeSelector: node-role.kubernetes.io/worker: '' # ...-
spec.template.spec.domain.devices.interfaces.namespecifies the name of the OVN-Kubernetes secondary interface. -
spec.template.spec.networks.namespecifies the name of the network. This must match the value of thespec.template.spec.domain.devices.interfaces.namefield. -
spec.template.spec.networks.multus.networkNamespecifies the name of theNetworkAttachmentDefinitionobject. -
spec.template.spec.nodeSelectorspecifies the nodes on which the VM can be scheduled. The recommended node selector value isnode-role.kubernetes.io/worker: ''.
-
Apply the
VirtualMachinemanifest:$ oc apply -f <filename>.yaml- Optional: If you edited a running virtual machine, you must restart it for the changes to take effect.