|
6 | 6 | [id="configuration-localnet-switched-topology_{context}"]
|
7 | 7 | = Configuration for a localnet switched topology
|
8 | 8 |
|
| 9 | +// To accommodate a link to the NMstate Operator, the content in this module |
| 10 | +// is split with tags. The tag includes don't pull in the module header above. |
| 11 | + |
| 12 | +// tag::localnet-intro[] |
9 | 13 | The switched (localnet) topology interconnects the workloads through a cluster-wide logical switch to a physical network.
|
| 14 | +// end::localnet-intro[] |
| 15 | + |
| 16 | +// tag::localnet-content[] |
| 17 | +You must map an additional network to the OVN bridge to use it as an OVN-Kubernetes additional network. Bridge mappings allow network traffic to reach the physical network. A bridge mapping associates a physical network name, also known as an interface label, to a bridge created with Open vSwitch (OVS). |
| 18 | + |
| 19 | +You can create an `NodeNetworkConfigurationPolicy` object, part of the `nmstate.io/v1` API group, to declaratively create the mapping. This API is provided by the NMState Operator. By using this API you can apply the bridge mapping to nodes that match your specified `nodeSelector` expression, such as `node-role.kubernetes.io/worker: ''`. |
| 20 | + |
| 21 | +When attaching an additional network, you can either use the existing `br-ex` bridge or create a new bridge. Which approach to use depends on your specific network infrastructure. |
| 22 | + |
| 23 | +- If your nodes include only a single network interface, you must use the existing bridge. This network interface is owned and managed by OVN-Kubernetes and you must not remove it from the `br-ex` bridge or alter the interface configuration. If you remove or alter the network interface, your cluster network will stop working correctly. |
| 24 | +- If your nodes include several network interfaces, you can attach a different network interface to a new bridge, and use that for your additional network. This approach provides for traffic isolation from your primary cluster network. |
| 25 | +
|
| 26 | +The `localnet1` network is mapped to the `br-ex` bridge in the following example: |
| 27 | + |
| 28 | +.Example mapping for sharing a bridge |
| 29 | +[source,yaml] |
| 30 | +---- |
| 31 | +apiVersion: nmstate.io/v1 |
| 32 | +kind: NodeNetworkConfigurationPolicy |
| 33 | +metadata: |
| 34 | + name: mapping <1> |
| 35 | +spec: |
| 36 | + nodeSelector: |
| 37 | + node-role.kubernetes.io/worker: '' <2> |
| 38 | + desiredState: |
| 39 | + ovn: |
| 40 | + bridge-mappings: |
| 41 | + - localnet: localnet1 <3> |
| 42 | + bridge: br-ex <4> |
| 43 | + state: present <5> |
| 44 | +---- |
| 45 | +<1> The name for the configuration object. |
| 46 | +<2> A node selector that specifies the nodes to apply the node network configuration policy to. |
| 47 | +<3> The name for the additional network from which traffic is forwarded to the OVS bridge. This additional network must match the name of the `spec.config.name` field of the `NetworkAttachmentDefinition` object that defines the OVN-Kubernetes additional network. |
| 48 | +<4> The name of the OVS bridge on the node. This value is required only if you specify `state: present`. |
| 49 | +<5> The state for the mapping. Must be either `present` to add the bridge or `absent` to remove the bridge. The default value is `present`. |
10 | 50 |
|
11 |
| -The following `NetworkAttachmentDefinition` custom resource definition (CRD) YAML describes the fields needed to configure a localnet secondary network. |
| 51 | +In the following example, the `localnet2` network interface is attached to the `ovs-br1` bridge. Through this attachment, the network interface is available to the OVN-Kubernetes network plugin as an additional network. |
12 | 52 |
|
| 53 | +.Example mapping for nodes with multiple interfaces |
13 | 54 | [source,yaml]
|
14 | 55 | ----
|
15 |
| - { |
16 |
| - "cniVersion": "0.3.1", |
17 |
| - "name": "ns1-localnet-network", |
18 |
| - "type": "ovn-k8s-cni-overlay", |
19 |
| - "topology":"localnet", |
20 |
| - "subnets": "202.10.130.112/28", |
21 |
| - "vlanID": 33, |
22 |
| - "mtu": 1500, |
23 |
| - "netAttachDefName": "ns1/localnet-network" |
24 |
| - "excludeSubnets": "10.100.200.0/29" |
25 |
| -
|
26 |
| - } |
27 |
| ----- |
| 56 | +apiVersion: nmstate.io/v1 |
| 57 | +kind: NodeNetworkConfigurationPolicy |
| 58 | +metadata: |
| 59 | + name: ovs-br1-multiple-networks <1> |
| 60 | +spec: |
| 61 | + nodeSelector: |
| 62 | + node-role.kubernetes.io/worker: '' <2> |
| 63 | + desiredState: |
| 64 | + interfaces: |
| 65 | + - name: ovs-br1 <3> |
| 66 | + description: |- |
| 67 | + A dedicated OVS bridge with eth1 as a port |
| 68 | + allowing all VLANs and untagged traffic |
| 69 | + type: ovs-bridge |
| 70 | + state: up |
| 71 | + bridge: |
| 72 | + options: |
| 73 | + stp: true |
| 74 | + port: |
| 75 | + - name: eth1 <4> |
| 76 | + ovn: |
| 77 | + bridge-mappings: |
| 78 | + - localnet: localnet2 <5> |
| 79 | + bridge: ovs-br1 <6> |
| 80 | + state: present <7> |
| 81 | +---- |
| 82 | +<1> The name for the configuration object. |
| 83 | +<2> A node selector that specifies the nodes to apply the node network configuration policy to. |
| 84 | +<3> A new OVS bridge, separate from the default bridge used by OVN-Kubernetes for all cluster traffic. |
| 85 | +<4> A network device on the host system to associate with this new OVS bridge. |
| 86 | +<5> The name for the additional network from which traffic is forwarded to the OVS bridge. This additional network must match the name of the `spec.config.name` field of the `NetworkAttachmentDefinition` object that defines the OVN-Kubernetes additional network. |
| 87 | +<6> The name of the OVS bridge on the node. This value is required only if you specify `state: present`. |
| 88 | +<7> The state for the mapping. Must be either `present` to add the bridge or `absent` to remove the bridge. The default value is `present`. |
| 89 | + |
| 90 | +This declarative approach is recommended because the NMState Operator applies additional network configuration to all nodes specified by the node selector automatically and transparently. |
| 91 | + |
| 92 | +The following JSON example configures a localnet secondary network: |
| 93 | + |
| 94 | +[source,json] |
| 95 | +---- |
| 96 | +{ |
| 97 | + "cniVersion": "0.3.1", |
| 98 | + "name": "ns1-localnet-network", |
| 99 | + "type": "ovn-k8s-cni-overlay", |
| 100 | + "topology":"localnet", |
| 101 | + "subnets": "202.10.130.112/28", |
| 102 | + "vlanID": 33, |
| 103 | + "mtu": 1500, |
| 104 | + "netAttachDefName": "ns1/localnet-network" |
| 105 | + "excludeSubnets": "10.100.200.0/29" |
| 106 | +} |
| 107 | +---- |
| 108 | +// end::localnet-content[] |
0 commit comments