How to Deploy and Test Multus CNI for Multi‑Network Pods in Kubernetes
This guide explains why Multus CNI is needed for multi‑network pods in Kubernetes, describes its architecture, walks through installing Multus alongside Calico and Flannel, shows how to configure NetworkAttachmentDefinitions, adjust Calico’s NIC selection, and demonstrates testing pod connectivity and routing limitations.
Background of Multus CNI
In a Kubernetes environment a pod normally has only two network interfaces (loopback and eth0). When an application needs both external API access and internal data‑plane traffic, a single NIC is insufficient, leading to latency and bottlenecks.
To meet production requirements many multi‑network solutions have emerged; Multus CNI is the most widely used because it follows the CNI spec, is stable and actively maintained.
What is Multus CNI
Multus CNI is an open‑source CNI‑compliant plugin that enables multiple network interfaces for a pod by delegating the actual network configuration to other CNI plugins. It does not provide network configuration itself.
When Multus is installed and additional CNI plugins are configured, a pod will have more interfaces than just eth0.
CNI Types
CNI plugins are classified into three types:
Main : creates container interfaces (bridge, ipvlan, macvlan, ptp, etc.).
IPAM : allocates IP addresses (host‑local, dhcp, static, calico‑ipam, whereabouts, etc.).
Meta : extends functionality (tuning, bandwidth, portmap, etc.). Multus belongs to the Meta class.
Deploying Multus CNI
In the test environment the primary CNI is Calico (IPIP mode). The following commands clone the Multus repository and apply the daemonset:
git clone https://github.com/k8snetworkplumbingwg/multus-cni.git && cd multus-cni/deployments
kubectl apply -f multus-daemonset-thick.ymlVerify the daemonset is running:
kubectl get ds -n kube-system | grep multusDeploying Flannel as an attachment network
Download the Flannel yaml, modify it to use eth1 as the interface, change the backend to vxlan, and apply it:
wget https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
# edit to set --iface=eth1 and backend vxlan
kubectl apply -f flannel.yamlCheck that the Flannel daemonset is running and that the binary appears on each node.
Creating NetworkAttachmentDefinition
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: flannel
spec:
config: '{
"cniVersion": "0.3.0",
"type": "flannel",
"delegate": {
"hairpinMode": true,
"isDefaultGateway": false
}
}'Apply it with kubectl apply -f flannel-nad.yaml.
Modifying Calico to use a specific NIC
Calico’s IP detection method can be changed from can‑reach to interface=eth0 via:
kubectl set env daemonset/calico-node -n kube-system IP_AUTODETECTION_METHOD=interface=eth0The daemonset restarts and the new environment variable can be verified inside a Calico pod.
Testing the multi‑network pod
Create a pod that requests the Flannel network:
apiVersion: v1
kind: Pod
metadata:
name: nginx
annotations:
k8s.v1.cni.cncf.io/networks: flannel
spec:
containers:
- name: nginx
image: nginx:latestAfter the pod is created, inspect its network namespaces. The pod has eth0 (Calico) and net1 (Flannel). Routing tables show the default route via eth0, so traffic to the Flannel network must be accessed explicitly.
Ping tests from the host and between pods confirm that the Calico IPs are reachable, while Flannel IPs are not reachable from outside because the default route does not use net1.
Limitations
Flannel does not support NetworkPolicy, so policies applied to eth0 will not affect traffic on the secondary interface.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
