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.
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.
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.provider
must be consistent with the provider in NetworkAttachmentDefinition.spec.vlan
of the subnet to the VLAN CR name you want to use. Configure other subnet parameters as needed.After creation, apply the resource:
Create a pod according to the following example.
metadata.annotations
must contain a key-value pair k8s.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.k8s.v1.cni.cncf.io/networks
as default/attachnet,default/attachnet2
.After the Pod is created successfully, use the command kubectl exec pod1 -- ip a
to view the Pod's IP addresses.
Use the following command to verify that the dual network interfaces have been created successfully:
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 ovn
in the Annotation Key is replaced with the corresponding NetworkAttachmentDefinition provider. Example: attachnet.default.ovn.kubernetes.io/ip_address=172.170.0.101
.
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: