1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/virt-attaching-vm-to-ovn-secondary-nw-cli.adoc
2025-11-18 16:29:25 +01:00

58 lines
1.8 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/vm_networking/virt-connecting-vm-to-ovn-secondary-network.adoc
:_mod-docs-content-type: PROCEDURE
[id="virt-attaching-vm-to-ovn-secondary-nw-cli_{context}"]
= Attaching a virtual machine to an OVN-Kubernetes secondary network using the CLI
[role="_abstract"]
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-admin` privileges.
* You have installed the OpenShift CLI (`oc`).
.Procedure
. Edit the `VirtualMachine` manifest to add the OVN-Kubernetes secondary network interface details, as in the following example:
+
[source,yaml]
----
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: vm-server
spec:
runStrategy: Always
template:
spec:
domain:
devices:
interfaces:
- name: secondary # <1>
bridge: {}
resources:
requests:
memory: 1024Mi
networks:
- name: secondary # <2>
multus:
networkName: <nad_name> # <3>
nodeSelector:
node-role.kubernetes.io/worker: '' # <4>
# ...
----
<1> The name of the OVN-Kubernetes secondary interface.
<2> The name of the network. This must match the value of the `spec.template.spec.domain.devices.interfaces.name` field.
<3> The name of the `NetworkAttachmentDefinition` object.
<4> Specifies the nodes on which the VM can be scheduled. The recommended node selector value is `node-role.kubernetes.io/worker: ''`.
. Apply the `VirtualMachine` manifest:
+
[source,terminal]
----
$ oc apply -f <filename>.yaml
----
. Optional: If you edited a running virtual machine, you must restart it for the changes to take effect.