mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
81 lines
3.4 KiB
Plaintext
81 lines
3.4 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-creating-localnet-nad-cli_{context}"]
|
|
= Creating a NAD for localnet topology using the CLI
|
|
|
|
You can create a network attachment definition (NAD) which describes how to attach a pod to the underlying physical network.
|
|
|
|
.Prerequisites
|
|
* You have access to the cluster as a user with `cluster-admin` privileges.
|
|
* You have installed the OpenShift CLI (`oc`).
|
|
* You have installed the Kubernetes NMState Operator.
|
|
|
|
.Procedure
|
|
|
|
. Create a `NodeNetworkConfigurationPolicy` object to map the OVN-Kubernetes secondary network to an Open vSwitch (OVS) bridge:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: nmstate.io/v1
|
|
kind: NodeNetworkConfigurationPolicy
|
|
metadata:
|
|
name: mapping # <1>
|
|
spec:
|
|
nodeSelector:
|
|
node-role.kubernetes.io/worker: '' # <2>
|
|
desiredState:
|
|
ovn:
|
|
bridge-mappings:
|
|
- localnet: localnet-network # <3>
|
|
bridge: br-ex # <4>
|
|
state: present # <5>
|
|
----
|
|
<1> The name of the configuration object.
|
|
<2> Specifies the nodes to which the node network configuration policy is to be applied. The recommended node selector value is `node-role.kubernetes.io/worker: ''`.
|
|
<3> The name of the additional network from which traffic is forwarded to the OVS bridge. This attribute must match the value of the `spec.config.name` field of the `NetworkAttachmentDefinition` object that defines the OVN-Kubernetes additional network.
|
|
<4> The name of the OVS bridge on the node. This value is required if the `state` attribute is `present`.
|
|
<5> The state of the mapping. Must be either `present` to add the mapping or `absent` to remove the mapping. The default value is `present`.
|
|
+
|
|
[NOTE]
|
|
====
|
|
{VirtProductName} does not support Linux bridge bonding modes 0, 5, and 6. For more information, see link:https://access.redhat.com/solutions/67546[Which bonding modes work when used with a bridge that virtual machine guests or containers connect to?].
|
|
====
|
|
|
|
. Create a `NetworkAttachmentDefinition` object:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: k8s.cni.cncf.io/v1
|
|
kind: NetworkAttachmentDefinition
|
|
metadata:
|
|
name: localnet-network
|
|
namespace: default
|
|
spec:
|
|
config: |-
|
|
{
|
|
"cniVersion": "0.3.1", <1>
|
|
"name": "localnet-network", <2>
|
|
"type": "ovn-k8s-cni-overlay", <3>
|
|
"topology": "localnet", <4>
|
|
"mtu": 1500, <5>
|
|
"netAttachDefName": "default/localnet-network" <6>
|
|
}
|
|
----
|
|
<1> The CNI specification version. The required value is `0.3.1`.
|
|
<2> The name of the network. This attribute must match the value of the `spec.desiredState.ovn.bridge-mappings.localnet` field of the `NodeNetworkConfigurationPolicy` object that defines the OVS bridge mapping.
|
|
<3> The name of the CNI plug-in to be configured. The required value is `ovn-k8s-cni-overlay`.
|
|
<4> The topological configuration for the network. The required value is `localnet`.
|
|
<5> Optional: The maximum transmission unit (MTU) value. If you do not set a value, the Cluster Network Operator (CNO) sets a default MTU value by calculating the difference among the underlay MTU of the primary network interface, the overlay MTU of the pod network, and byte capacity of any enabled features, such as IPsec.
|
|
<6> The value of the `namespace` and `name` fields in the `metadata` stanza of the `NetworkAttachmentDefinition` object.
|
|
|
|
. Apply the manifest:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc apply -f <filename>.yaml
|
|
----
|
|
|