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-primary-udn.adoc
2025-11-18 16:29:25 +01:00

65 lines
2.1 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/vm_networking/virt-connecting-vm-to-primary-udn.adoc
:_mod-docs-content-type: PROCEDURE
[id="virt-attaching-vm-to-primary-udn_{context}"]
= Attaching a virtual machine to the primary user-defined network by using the CLI
[role="_abstract"]
You can connect a virtual machine (VM) to the primary user-defined network (UDN) by using the CLI.
.Prerequisites
* You have installed the OpenShift CLI (`oc`).
.Procedure
. Edit the `VirtualMachine` manifest to add the UDN interface details, as in the following example:
+
Example `VirtualMachine` manifest:
+
[source,yaml]
----
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: example-vm
namespace: my-namespace # <1>
spec:
template:
spec:
domain:
devices:
interfaces:
- name: udn-l2-net # <2>
binding:
name: l2bridge # <3>
# ...
networks:
- name: udn-l2-net # <4>
pod: {}
# ...
----
<1> The namespace in which the VM is located. This value must match the namespace in which the UDN is defined.
<2> The name of the user-defined network interface.
<3> The name of the binding plugin that is used to connect the interface to the VM. The possible values are `l2bridge` and `passt`. The default value is `l2bridge`.
<4> The name of the network. This must match the value of the `spec.template.spec.domain.devices.interfaces.name` field.
. Optional: If you are using the Plug a Simple Socket Transport (passt) network binding plugin, set the `hco.kubevirt.io/deployPasstNetworkBinding` annotation to `true` in the `HyperConverged` custom resource (CR) by running the following command:
+
--
[source,terminal]
----
$ oc annotate hco kubevirt-hyperconverged -n kubevirt-hyperconverged hco.kubevirt.io/deployPasstNetworkBinding=true --overwrite
----
:FeatureName: Using the passt binding plugin to attach a VM to the primary UDN
include::snippets/technology-preview.adoc[]
--
. Apply the `VirtualMachine` manifest by running the following command:
+
[source,terminal]
----
$ oc apply -f <filename>.yaml
----