:_mod-docs-content-type: ASSEMBLY
include::_attributes/common-attributes.adoc[]
[id="virt-connecting-vm-to-primary-udn"]
= Connecting a virtual machine to a primary user-defined network
:context: virt-connecting-vm-to-primary-udn

toc::[]

[role="_abstract"]
You can connect a virtual machine (VM) to a user-defined network (UDN) on the VM's primary interface. The primary UDN replaces the default pod network in your specified namespace. You can define the primary UDN per project, where each project can use its specific subnet and topology.

{VirtProductName} supports the namespace-scoped `UserDefinedNetwork` and the cluster-scoped `ClusterUserDefinedNetwork` custom resource definitions (CRD).

Cluster administrators can configure a primary `UserDefinedNetwork` CRD to create a tenant network that isolates the tenant namespace from other namespaces without requiring network policies. Additionally, cluster administrators can use the `ClusterUserDefinedNetwork` CRD to create a shared OVN network across multiple namespaces.

[NOTE]
====
You must add the `k8s.ovn.org/primary-user-defined-network` label when you create a namespace that is to be used with user-defined networks.
====

With the layer 2 topology, OVN-Kubernetes creates an overlay network between nodes. You can use this overlay network to connect VMs on different nodes without having to configure any additional physical networking infrastructure.

The layer 2 topology enables seamless migration of VMs without the need for Network Address Translation (NAT) because persistent IP addresses are preserved across cluster nodes during live migration.

You must consider the following limitations before implementing a primary UDN:

* You cannot use the `virtctl ssh` command to configure SSH access to a VM.
* You cannot use the `oc port-forward` command to forward ports to a VM.
* You cannot use headless services to access a VM.

include::modules/virt-creating-primary-udn-web-intro.adoc[leveloffset=+1]

include::modules/virt-creating-udn-namespace-web.adoc[leveloffset=+2]

include::modules/virt-creating-primary-udn-web.adoc[leveloffset=+2]

include::modules/virt-creating-a-localnet-cudn-web.adoc[leveloffset=+2]

include::modules/virt-creating-primary-cluster-udn-web.adoc[leveloffset=+2]

include::modules/virt-creating-primary-udn-cli-intro.adoc[leveloffset=+1]

include::modules/virt-creating-udn-namespace-cli.adoc[leveloffset=+2]

include::modules/virt-creating-a-primary-udn.adoc[leveloffset=+2]

include::modules/virt-creating-a-primary-cluster-udn.adoc[leveloffset=+2]

include::modules/virt-attaching-vm-to-primary-udn-intro.adoc[leveloffset=+1]

include::modules/virt-creating-vm-in-primary-udn-web.adoc[leveloffset=+2]

include::modules/virt-attaching-vm-to-primary-udn.adoc[leveloffset=+2]

//Excluding from ROSA because the Networking -> Multiple networks -> Primary networks section is not part of ROSA docs
ifndef::openshift-rosa,openshift-dedicated,openshift-rosa-hcp[]
[role="_additional-resources"]
[id="additional-resources_{context}"]
== Additional resources
* xref:../../networking/multiple_networks/primary_networks/about-user-defined-networks.adoc#about-user-defined-networks[About user-defined networks]
endif::openshift-rosa,openshift-dedicated,openshift-rosa-hcp[]
