You can prepare the node network for a localnet topology by creating a NodeNetworkConfigurationPolicy (NNCP) custom resource (CR) that configures an Open vSwitch (OVS) bridge and maps it to the physical network.
If you use a dedicated network interface for VM traffic, you must configure the full OVS bridge, including the uplink, internal interface, and bridge mapping. If you share the default machine network, you only need to add the bridge mapping to the existing br-ex bridge.
Prerequisites
-
You are logged in 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 manifest to configure the OVS bridge and map it to the physical network. The following example uses two dedicated uplink interfaces bonded with OVS balance-slb mode and configures jumbo frames.
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
name: bridge-config-group-1
spec:
nodeSelector:
vm-network-configuration: group-1
desiredState:
interfaces:
- name: eno1np0
type: ethernet
state: up
mtu: 9000
- name: eno2np1
type: ethernet
state: up
mtu: 9000
- name: br1
type: ovs-bridge
state: up
bridge:
allow-extra-patch-ports: true
options:
stp: false
mcast-snooping-enable: true
port:
- name: bond1
link-aggregation:
mode: balance-slb
port:
- name: eno1np0
- name: eno2np1
- name: br1
- name: br1
type: ovs-interface
state: up
mtu: 9000
ipv4:
enabled: false
ipv6:
enabled: false
ovn:
bridge-mappings:
- localnet: provider-network
bridge: br1
state: present
spec.nodeSelector
-
Selects the nodes to which the node network configuration policy is applied. Use node selectors when your cluster has heterogeneous hardware where network interface names differ across node groups.
spec.desiredState.interfaces (ethernet)
-
Specifies the uplink interfaces and their MTU. Set the desired MTU on the uplink interfaces to match the physical network. In this example, jumbo frames are configured with an MTU of 9000.
spec.desiredState.interfaces (ovs-bridge)
-
Specifies the OVS bridge configuration. The bridge name must match the name used in the ovn.bridge-mappings.bridge field.
bridge.allow-extra-patch-ports
-
Must be set to true to allow the creation of multiple OVS patch ports, which is required for VM networks.
bridge.options.stp
-
Must be set to false to allow VMs to live migrate between nodes.
bridge.options.mcast-snooping-enable
-
Set to true to prevent flooding multicast packets to every port on the bridge.
bridge.port (link-aggregation)
-
Specifies the bonding mode for the uplink interfaces. The balance-slb mode balances traffic based on source MAC address and VLAN without requiring special switch configuration.
spec.desiredState.interfaces (ovs-interface)
-
Specifies the internal OVS interface. This interface is required for correct OVS operation. Use the same name for the internal OVS interface as the OVS bridge.
ovn.bridge-mappings.localnet
-
Specifies the localnet identifier. This value must match the spec.network.localnet.physicalNetworkName field of the ClusterUserDefinedNetwork CR that defines the localnet network.
ovn.bridge-mappings.bridge
-
Specifies the name of the OVS bridge on the node.
ovn.bridge-mappings.state
-
Specifies the state of the mapping. Set to present to add the mapping or absent to remove it. The default value is present.
-
Optional: If you share the default machine network with VM traffic instead of using a dedicated interface, the bridge and its uplinks are configured during cluster deployment. You only need to configure the bridge mapping. In this example, the machine network belongs to the native VLAN and the br-ex bridge is configured directly on the uplink, not on a VLAN sub-interface.
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
name: network-config
spec:
desiredState:
ovn:
bridge-mappings:
- localnet: provider-network
bridge: br-ex
state: present
-
Apply the NodeNetworkConfigurationPolicy manifest by running the following command:
$ oc apply -f <filename>.yaml
<filename>
-
Specifies the name of your NodeNetworkConfigurationPolicy manifest YAML file.