Configuring Kube-OVN Network to Support Pod Multi-Network Interfaces (Alpha)
By using Multus CNI, you can add multiple network interfaces with different networks to Pods. Use Kube-OVN network's Subnet and IP CRDs for advanced IP management, implementing subnet management, IP reservation, random allocation, fixed allocation, and other features.
TOC
Installing Multus CNI
Deploying the Multus CNI Plugin
-
Go to Administrator.
-
In the left navigation bar, click Marketplace > Cluster Plugins.
-
In the search bar, type "multus" to find the Multus CNI plugin.
-
Locate the "Alauda Container Platform Networking for Multus" plugin in the list.
-
Click the three dots (⋮) next to the plugin entry and select Install.
-
The plugin will be deployed to your cluster. You can monitor the installation status in the State column.
The Multus CNI plugin serves as middleware between other CNI plugins and Kubernetes, enabling Pods to have multiple network interfaces.
Creating Subnets
Create an attachnet subnet according to the following 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.
After creation, apply the resource:
Use the following example to create the Kube-OVN subnet for the second network interface: subnet.yml.
spec.providermust be consistent with the provider in NetworkAttachmentDefinition.- If you need to use an Underlay subnet, set the
spec.vlanof the subnet to the VLAN CR name you want to use. Configure other subnet parameters as needed.
After creation, apply the resource:
Creating Pod with Multiple Network Interfaces
Create a pod according to the following example.
- The
metadata.annotationsmust contain a key-value pairk8s.v1.cni.cncf.io/networks=default/attachnet, where the value format is<NAMESPACE>/<NAME>, and<NAMESPACE>and<NAME>are the namespace and name of the NetworkAttachmentDefinition CR respectively. - If the Pod needs three network interfaces, configure the value of
k8s.v1.cni.cncf.io/networksasdefault/attachnet,default/attachnet2.
After the Pod is created successfully, use the command kubectl exec pod1 -- ip a to view the Pod's IP addresses.
Verifying Dual Network Interface Creation
Use the following command to verify that the dual network interfaces have been created successfully:
Additional Features
Fixed IP
-
Primary Network Interface (First Interface): If you need to fix the IP of the primary network interface, the method is the same as using a fixed IP with a single network interface. Add the annotation
ovn.kubernetes.io/ip_address=<IP>to the Pod. -
Secondary Network Interface (Second Interface or Other Interfaces): The basic method is similar to the primary network interface, with the difference that the
ovnin the Annotation Key is replaced with the corresponding NetworkAttachmentDefinition provider. Example:attachnet.default.ovn.kubernetes.io/ip_address=172.170.0.101.
Additional Routes
Starting from version 1.8.0, Kube-OVN supports configuring additional routes for secondary network interfaces. When using this feature, add the routers field to the config in NetworkAttachmentDefinition and fill in the routes you need to configure. Example: