CNI
Container Network Interface
CNI (Container Network Interface) is the networking plugin standard for Kubernetes and container runtimes. Pod-to-Pod communication is implemented through various CNI plugins such as Flannel, Calico, and Cilium.
Container Network Interface
CNI (Container Network Interface) is the networking plugin standard for Kubernetes and container runtimes. Pod-to-Pod communication is implemented through various CNI plugins such as Flannel, Calico, and Cilium.
CNI (Container Network Interface) is a standard interface between a container runtime and network plugins. Managed by the CNCF (Cloud Native Computing Foundation), it is the core mechanism by which Kubernetes assigns networking to Pods and enables communication between Pods. Without a CNI, the Pods in a Kubernetes cluster cannot communicate with each other.
CNI was started by CoreOS in 2015. Unlike Docker's libnetwork, it was designed with a focus on simplicity and extensibility. When a container is created, the kubelet calls the CNI plugin to set up the network namespace and assign an IP. When the container is deleted, the network resources are cleaned up in reverse.
Representative CNI plugins include Flannel (the simplest, VXLAN-based), Calico (network policy + BGP routing), Cilium (eBPF-based, L7 policy), Weave Net (encryption support), and AWS VPC CNI (AWS-native IP allocation). In production environments, Calico is the most widely used, and Cilium is chosen when advanced features are needed.
Kubernetes' network model follows the principle that "every Pod can communicate with every other Pod without NAT." To implement this principle, CNI plugins use an overlay network (VXLAN, IPIP), an underlay network (BGP), or a cloud-native approach (AWS VPC CNI).
# Calico CNI 설치 (가장 널리 사용)
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/tigera-operator.yaml
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/custom-resources.yaml
# 설치 확인
kubectl get pods -n calico-system
watch kubectl get pods -n calico-system
# Calico 네트워크 정책 예제 (특정 Pod만 통신 허용)
cat <
# Flannel CNI 설치 (가장 단순)
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
# 설치 확인
kubectl get pods -n kube-flannel
kubectl get nodes -o wide
# Flannel 설정 확인
kubectl get configmap kube-flannel-cfg -n kube-flannel -o yaml
# Flannel CIDR 확인
cat /run/flannel/subnet.env
# FLANNEL_NETWORK=10.244.0.0/16
# FLANNEL_SUBNET=10.244.0.1/24
# 노드별 Pod CIDR 확인
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.podCIDR}{"\n"}{end}'
# Flannel 로그 확인 (문제 해결 시)
kubectl logs -n kube-flannel -l app=flannel
# kubeadm 초기화 시 Pod CIDR 지정 (Flannel 기본값)
# kubeadm init --pod-network-cidr=10.244.0.0/16
# Cilium CNI 설치 (eBPF 기반, 고급 기능)
# Cilium CLI 설치
CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt)
curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-amd64.tar.gz
sudo tar xzvfC cilium-linux-amd64.tar.gz /usr/local/bin
# Cilium 설치
cilium install --version 1.14.2
# 설치 상태 확인
cilium status --wait
# 연결성 테스트
cilium connectivity test
# L7 네트워크 정책 (HTTP 메소드 기반 제어)
cat <
🗣️ Say It Like This in Practice
💬 In a Kubernetes cluster setup discussion
"After kubeadm init, you need to install a CNI before the nodes become Ready. Our team uses Calico, which provides network policy by default and also supports BGP routing, so it scales well. If you just need an overlay, Flannel is lightweight and good."
💬 In an Interview
"CNI is the standard interface through which the container runtime sets up the network namespace and assigns an IP. When the kubelet creates a Pod, it reads the configuration in /etc/cni/net.d/ and executes the binaries in /opt/cni/bin/. In practice, in Calico's case, Felix manages the iptables rules, and BIRD exchanges routing information via BGP."
💬 In a meeting with the security team
"By default, Kubernetes lets every Pod communicate with every other Pod, which is a security risk. We need to apply NetworkPolicy with Calico or Cilium to isolate namespaces and allow only specific ports. Cilium also supports L7 policy, so it can control traffic at the level of HTTP methods."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
⚠️ Common Mistakes & Cautions
Using kubectl without a CNI
If you do not install a CNI after kubeadm init, the nodes remain in the NotReady state. The coredns Pods also stay in the Pending state. Be sure to install a CNI immediately after cluster initialization.
Pod CIDR conflicts
If the CNI's Pod CIDR (e.g., 10.244.0.0/16) overlaps with the host network or the VPC CIDR, routing problems occur. Use the kubeadm init --pod-network-cidr option to specify a range that does not conflict.
Mixing CNI plugins
Installing multiple CNIs in a single cluster causes unpredictable behavior. Completely remove the existing CNI before installing a new one. Be especially careful when migrating from Flannel to Calico.
Guide to choosing the right CNI
Choose Flannel (simplicity) for development/test environments, Calico (stability + network policy) for production, Cilium (eBPF-based) if you need advanced observability/security, and AWS VPC CNI (native performance) for AWS EKS.
🔗 Related Terms
📚 Learn More