Skip to content
LinkState
Go back

Advertising Pod CIDRs or Summarizing at the Node Edge

Introduction to CNI and Pod Networking

Overview of CNI and Its Role in Kubernetes

The Container Network Interface (CNI) is a specification and libraries for configuring network interfaces in Linux containers. In Kubernetes, the kubelet invokes the CNI plugin during pod creation to allocate an IP address, set up the pod’s network namespace, and configure routes that enable intra‑cluster communication. The plugin therefore determines how pod IP addresses are visible to the rest of the cluster and, optionally, to external networks.

Pod Networking Fundamentals

Each pod receives a unique IP address from a cluster‑wide CIDR (e.g., 10.244.0.0/16). Containers inside the pod share this address and can communicate via localhost. For a pod to reach another pod, the underlying network must provide a path between the two IP addresses. Three common forwarding models exist:

  1. Direct routing – pod prefixes are programmed into the underlying fabric (e.g., via BGP or static routes) so that packets travel natively without extra encapsulation.
  2. Node‑level summarization – each node advertises a single route that covers all pods hosted on that node (typically the node’s own /32 or a larger aggregate). Packets are first sent to the node, then delivered locally via an overlay or ARP.
  3. Full encapsulation – pod‑to‑pod traffic is encapsulated (e.g., VXLAN, IP‑in‑IP, Geneve) and carried over the underlying L2/L3 network; the underlay sees only node IPs.

The choice of model influences reachability, failure isolation, and operational overhead.

Leaking Exact Pod Prefixes Upstream

Advantages of Leaking Pod Prefixes

Disadvantages of Leaking Pod Prefixes

Reachability Concerns

Failure Isolation Challenges

Debugging Complexity

Summarizing Behind Node Routes

Benefits of Node Route Summarization

Drawbacks of Node Route Summarization

Impact on Reachability

Effects on Failure Isolation

Debugging Considerations

Staying Encapsulated

Advantages of Encapsulation

Disadvantages of Encapsulation

Reachability Limitations

Failure Isolation Benefits

Debugging Tradeoffs

Troubleshooting CNI Configuration Issues

Identifying Common Configuration Mistakes

Using CLI Tools for Debugging

Example: Using kubectl for Troubleshooting

# List pods with their IPs and node assignment
kubectl get pods -o wide

# Describe a pod to see events (e.g., CNI timeout)
kubectl describe pod <pod-name> -n <namespace>

# Get the CNI config used on a node
kubectl get node <node-name> -o jsonpath='{.metadata.annotations.cni\\.projectcalico\\.org/ipv4pools}'

Example: Using ip Command for Network Inspection

# Show routes installed by the CNI on a node
ip route show table main | grep -E '10\.244\.|flannel\.|calico'

# Inspect VXLAN device (if encapsulation used)
ip -d link show vxlan.calico

# Display FDB entries for a VXLAN device (shows which pod MAC is reachable via which remote VTEP)
bridge fdb show dev vxlan.calico

# Check BGP session state (if using FRR or bird)
vtysh -c "show ip bgp summary"

These commands help distinguish whether a connectivity problem stems from missing underlay routes, encapsulation failures, or IPAM conflicts.

Code Examples for CNI Configuration

Leaking Pod Prefixes Example

YAML Configuration Snippet (Calico BGP Advertising Pod /32s)

apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
  name: default-ippool
spec:
  cidr: 10.244.0.0/16
  ipipMode: Never               # Disable encapsulation
  natOutgoing: false            # Do not SNAT pod traffic
  nodeSelector: all()           # Apply to all nodes
  bgp:
    advertise: true             # Advertise each pod IP as a /32
    advertiseClusterIPs: false  # Do not advertise Service cluster IPs

CLI Command for Applying Configuration

kubectl apply -f calico-bgp-pod-prefixes.yaml

Assumption: A BGP speaker (e.g., Calico’s bird or external FRR) is running on each node and peered with the fabric.

Node Route Summarization Example

YAML Configuration Snippet (Flannel host‑gw mode)

# flannel-config ConfigMap (applied via kube-flannel.yml)
kind: ConfigMap
apiVersion: v1
metadata:
  name: kube-flannel-cfg
  namespace: kube-system
data:
  cni.conf: |
    {
      "name": "cbr0",
      "type": "flannel",
      "delegate": {
        "isDefaultGateway": true
      }
    }
  net-conf.json: |
    {
      "Network": "10.244.0.0/16",
      "Backend": {
        "Type": "host-gw"
      }
    }

CLI Command for Applying Configuration

kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml

Assumption: The underlying network allows L2 connectivity between nodes so that each node can install a route for the pod CIDR via the neighbor’s IP (host‑gw).

Encapsulation Example

YAML Configuration Snippet (Calico IP‑in‑IP)

apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
  name: ipip-pool
spec:
  cidr: 10.244.0.0/16
  ipipMode: Always          # Encapsulate with IP‑in‑IP
  natOutgoing: true
  nodeSelector: all()
  vxlanMode: Never

CLI Command for Applying Configuration

kubectl apply -f calico-ipip.yaml

Assumption: The underlying network permits IP protocol 4 (IP‑in‑IP) between nodes; firewalls must not drop it.

Scaling Limitations and Considerations

Scalability Tradeoffs for Each Approach

Leaking Pod Prefixes Scalability

Node Route Summarization Scalability


Share this post on:

Previous Post
Staged segmentation changes with permit shadowing
Next Post
State changes that separate churn from path loss