Configuring Kube-OVN Network to Support Pod Multi-Network Interfaces
This guide describes how to configure Kube-OVN so that a Pod can use multiple network interfaces.
With Multus CNI and Kube-OVN, you can attach a secondary network to a Pod and manage IP addresses for that network through Kube-OVN Subnet and IPAM.
- IPv4, IPv6 and dual-stack networks are all supported for both primary and secondary network interfaces.
- Both underlay and overlay networks are supported as secondary networks.
TOC
Before You BeginInstalling Multus CNIDeploying the Multus CNI PluginCreate the Secondary NetworkCreate a Pod with Multiple Network InterfacesVerify the Network InterfacesMethod 1: Check Pod AnnotationsMethod 2: Check Network Interfaces from Inside the PodMethod 3: Check Kube-OVN IP ResourcesOptional ConfigurationsFixed IPAdditional RoutesConfigure Additional Routes for All Pods Referencing the Same NetworkAttachmentDefinitionConfigure Additional Routes for a Specific Pod/WorkloadVerify Additional Routes in the Pod Route TableBefore You Begin
Make sure the following conditions are met:
- The cluster uses Kube-OVN as the network plugin.
- You have permissions to install cluster plugins and create Kubernetes resources.
kubectlis configured and can access the target cluster.
Installing Multus CNI
Deploying the Multus CNI Plugin
-
Navigate to Administrator > Marketplace > Cluster Plugins.
-
Search "multus" and select "Alauda Container Platform Networking for Multus".
-
If the plugin is not installed, click the three dots (â‹®) on the right and select Install.
-
Wait for the plugin state to change to "Installed".
The Multus CNI plugin serves as middleware between other CNI plugins and Kubernetes, enabling Pods to have multiple network interfaces.
Create the Secondary Network
To add a secondary network interface to a Pod, first create a NetworkAttachmentDefinition for that network.
Example: network-attachment-definition.yml
The provider format in config is <NAME>.<NAMESPACE>.ovn, where <NAME> and <NAMESPACE> are the name and namespace of this NetworkAttachmentDefinition CR respectively.
If you use an underlay secondary network, set spec.vlan in the Subnet to the target VLAN CR name.
Apply the resource:
Then create a Kube-OVN subnet for the secondary network interface.
Example: subnet.yml
spec.provider MUST be consistent with the provider in NetworkAttachmentDefinition.
Apply the resource:
Create a Pod with Multiple Network Interfaces
After the secondary network is ready, create a Pod and reference the NetworkAttachmentDefinition in metadata.annotations.
- The annotation
k8s.v1.cni.cncf.io/networksuses the format<NAMESPACE>/<NAME>, where<NAMESPACE>and<NAME>are the namespace and name of the corresponding NetworkAttachmentDefinition. - To attach multiple secondary networks, specify multiple values separated by commas, for example
default/attachnet,default/attachnet2.
For workloads that require multiple network interfaces, you can also specify the network attachment annotation in the Pod template of a higher-level controller such as Deployment or StatefulSet. Example:
Verify the Network Interfaces
After the Pod is running, verify the result by using the following methods.
Method 1: Check Pod Annotations
Run the following command:
Check the relevant annotations in the output:
Annotation k8s.v1.cni.cncf.io/network-status shows the status of all network interfaces of this Pod, including the primary interface and secondary interfaces.
In this example, the Pod has two network interfaces: eth0 is the primary interface, and net1 is the secondary interface.
Method 2: Check Network Interfaces from Inside the Pod
Run one of the following commands:
The command availability depends on the container image. If one command is not available in the image, use the other one.
Example output of ip addr show:
Method 3: Check Kube-OVN IP Resources
Run the following command to verify IP allocation records for both interfaces:
Example output:
Optional Configurations
Fixed IP
-
Primary network interface: To assign a fixed IP address to the primary interface, add the annotation
ovn.kubernetes.io/ip_address=<IP>to the Pod. -
Secondary network interface: To assign a fixed IP address to a secondary interface, replace
ovnin the annotation key with the corresponding NetworkAttachmentDefinition provider. Example:attachnet.default.ovn.kubernetes.io/ip_address=172.22.0.101.
For workloads such as Deployment or StatefulSet, you can specify the fixed IP annotation in the Pod template.
Additional Routes
You can configure additional routes for all Pods that reference the same NetworkAttachmentDefinition or a specific Pod/Workload.
Configure Additional Routes for All Pods Referencing the Same NetworkAttachmentDefinition
To configure additional routes for all secondary network interfaces that reference the same NetworkAttachmentDefinition, add the routes field in the NetworkAttachmentDefinition config. Example:
Replace the route gateway values with valid addresses that are reachable from the secondary network in your environment.
Configure Additional Routes for a Specific Pod/Workload
To configure additional routes for a specific secondary network interface, add the annotation attachnet.default.ovn.kubernetes.io/routes to the Pod. Example:
For workloads such as Deployment or StatefulSet, you can also specify the routes annotation in the Pod template. Example:
Verify Additional Routes in the Pod Route Table
After configuring routes, verify the effective route entries inside the Pod:
Or, if ip is not available in the container image, use route -n:
Example output of ip route show:
If the corresponding destination and gateway route does not appear in the output, check the routes configuration in NetworkAttachmentDefinition or Pod annotations, and then recreate the Pod to re-apply CNI configuration.