Skip to content

Files

Latest commit

 

History

History
56 lines (49 loc) · 2.85 KB

virt-creating-layer2-nad-cli.adoc

File metadata and controls

56 lines (49 loc) · 2.85 KB

Creating a NAD for layer 2 topology using the CLI

You can create a network attachment definition (NAD) which describes how to attach a pod to the layer 2 overlay network.

Prerequisites
  • You have access to the cluster as a user with cluster-admin privileges.

  • You have installed the OpenShift CLI (oc).

Procedure
  1. Create a NetworkAttachmentDefinition object:

    apiVersion: k8s.cni.cncf.io/v1
    kind: NetworkAttachmentDefinition
    metadata:
      name: l2-network
      namespace: my-namespace
    spec:
      config: |2
        {
                "cniVersion": "0.3.1", (1)
                "name": "my-namespace-l2-network", (2)
                "type": "ovn-k8s-cni-overlay", (3)
                "topology":"layer2", (4)
                "subnets": "192.168.10.0/29", (5)
                "mtu": 1300, (6)
                "netAttachDefName": "my-namespace/l2-network", (7)
                "excludeSubnets": "192.168.10.1/32, 192.168.10.2/32, 192.168.10.3/32, 192.168.10.4/32", (8)
                "allowPersistentIPs": "true" (9)
        }
    1. The CNI specification version. The required value is 0.3.1.

    2. The name of the network. This attribute is not namespaced. For example, you can have a network named l2-network referenced from two different NetworkAttachmentDefinition objects that exist in two different namespaces. This feature is useful to connect VMs in different namespaces.

    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 layer2.

    5. Optional: A comma-separated list of subnets. If you specify multiple subnets, IP addresses are assigned from each subnet. When the subnets field is omitted, the logical switch implementing the network only provides layer 2 communication. You must configure an IP address when you create the VM by either setting a static IP address or by deploying a DHCP server on the network for a dynamic IP address.

    6. Optional: The maximum transmission unit (MTU) value. The default value is automatically set by the kernel.

    7. The value of the namespace and name fields in the metadata stanza of the NetworkAttachmentDefinition object.

    8. Optional: A comma-separated list of CIDRs and IP addresses. IP addresses are removed from the assignable IP address pool and are not passed to the pods.

    9. Optional: When set to true, the assigned IP addresses persist of a VM connected to this secondary network persist in an IPClaims object after live migration These IP addresses are reused by other pods, if requested. This works only if the subnets attribute is also defined.

  2. Apply the manifest:

    $ oc apply -f <filename>.yaml