Configure MTU

In Kube-OVN, the MTU (Maximum Transmission Unit) setting is crucial for ensuring optimal network performance and avoiding packet fragmentation. The MTU defines the maximum size of a packet that can be transmitted over the network.

By default, Kube-OVN detects the MTU of the underlying physical network interface and sets the MTU for the virtual network interfaces accordingly. However, there are scenarios where you might need to customize the MTU settings for your Kube-OVN networking components.

Default MTU Behavior

Kube-OVN automatically detects the MTU of the physical network interface on the host machine, and sets the MTU for the Pod and OVS interfaces accordingly.

In overlay networks, Kube-OVN reduces the MTU to accommodate the VXLAN or Geneve encapsulation overhead. Here is how the MTU is calculated:

Encapsulation TypeTunnel IP VersionMTU Calculation
GeneveIPv4Physical Network Interface MTU - 100
IPv6Physical Network Interface MTU - 120
VXLANIPv4Physical Network Interface MTU - 50
IPv6Physical Network Interface MTU - 70

In underlay networks, the MTU is set to match the physical network interface MTU.

Customizing MTU Settings

MTU settings can be customized globally for overlay networks or on a per-subnet basis.

WARNING

Adjusting MTU settings incorrectly can lead to network performance issues, including packet loss and fragmentation. Ensure that the MTU settings are compatible with your underlying network infrastructure before making changes.

NOTE

MTU configuration changes will only take effect for newly created Pods. Existing Pods will retain their original MTU settings until they are recreated. It's recommended to plan for Pod restarts when changing MTU settings.

Global MTU Configuration

To set a global MTU for overlay networks, you can modify the command parameter of the kube-ovn-cni DaemonSet. For example, to set the global MTU to 1400, you would update the DaemonSet as follows:

kubectl -n kube-system edit ds kube-ovn-cni

Then, add or update the --mtu=1400 parameter to the container's arguments:

apiVersion: apps/v1
kind: DaemonSet
metadata:
    kubernetes.io/description: |
      This daemon set launches the kube-ovn cni daemon.
  name: kube-ovn-cni
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: kube-ovn-cni
  template:
    metadata:
      labels:
        app: kube-ovn-cni
        component: network
        type: infra
    spec:
      containers:
      - name: cni-server
        args:
        - --mtu=1400
NOTE

The global MTU setting only affects overlay networks. For underlay networks, the MTU remains the same as the physical network interface MTU by default.

Per-Subnet MTU Configuration

You can also set the MTU for individual subnets by specifying the mtu field in the subnet configuration. For example, to set the MTU for a specific subnet to 1450, you can use the following command:

kubectl patch subnet my-subnet --type merge -p '{"spec": {"mtu": 1450}}'

This setting will override the global MTU setting for that particular subnet.