Day 15: Overlay and MTU
Goal: You find Cilium’s VXLAN overlay, see a pod packet in its envelope on the wire, calculate why pods only get 1450 bytes, and hunt down an MTU black hole: small responses arrive instantly, large ones take seconds – without a single error message. At the end you adapt the overlay to a smaller underlay · Duration: approx. 90 min · Prerequisite: Day 12 (cluster
ndbgwith Cilium andwerkzeug)
Briefing
- Pods on different nodes talk over an overlay: Cilium wraps a pod’s packet in a UDP packet between the nodes (VXLAN, port 8472 in Cilium; Geneve works the same way, port 6081). The network between the nodes – the underlay – only sees node addresses.
- The envelope costs 50 bytes: 14 Ethernet + 20 IP + 8 UDP + 8 VXLAN. An underlay with MTU 1500 therefore leaves 1450 bytes for the pod packet. Cilium writes this number as the MTU into the route of every pod.
- If a packet does not fit through, a router should send back “Fragmentation needed” (ICMP), and the sender shrinks its packets. If this message is missing – a firewall filters ICMP, a switch drops silently –, you get an MTU black hole: connection setup and small responses work, large packets disappear.
- Typical symptoms: the TLS handshake hangs (the certificate chain is
large),
kubectl logsbreaks off, downloads above a certain size take forever, “it works on the same node, not across nodes”.
| Size | what | Pod MTU 1450 |
|---|---|---|
ping -s 1422 |
1422 data + 8 ICMP + 20 IP = 1450 | fits exactly |
ping -s 1423 |
1451 bytes | too large, already rejected in the pod |
| Envelope | pod packet + 50 | 1500 on the underlay |
Drill 1: Where is the overlay?
# on netz
# Cilium's routing mode and tunnel protocol
cilium config view | grep -E "^(routing-mode|tunnel-protocol)"
# in the pod: address, MTU of the interface, routes
kubectl exec werkzeug -- ip -br addr show eth0
kubectl exec werkzeug -- ip link show eth0 | grep -o "mtu [0-9]*"
kubectl exec werkzeug -- ip route
# on the node: Cilium's VXLAN device (-d = details, grep -o = only the matches)
sudo docker exec ndbg-worker ip -d link show cilium_vxlan | grep -oE "dstport [0-9]+|external"Expected:
routing-mode tunnel
tunnel-protocol vxlan
eth0@if11 UP 10.244.1.135/32 fe80::1453:dfff:fe8b:690/64
mtu 1500
default via 10.244.1.250 dev eth0 mtu 1450
10.244.1.250 dev eth0 scope link
dstport 8472
external
The pod’s interface has MTU 1500, but the route says
mtu 1450 – and the route wins. That way the interface stays
normal, and the pod still never sends more than 1450 bytes. The VXLAN
device on the node runs in external mode: there is no fixed
peer; Cilium’s eBPF program decides for every packet which node the
envelope goes to.
Save your progress? Sign up for free
Drill 2: VXLAN on the wire
Both nodes are attached in Docker to the bridge of the
kind network on netz. That is where you see
the envelopes. A ping from the tools pod (worker) to a CoreDNS pod
(control plane):
# on netz
# IP of the CoreDNS pod on the control plane (--field-selector = only pods on this node)
D=$(kubectl -n kube-system get pod -l k8s-app=kube-dns --field-selector spec.nodeName=ndbg-control-plane -o jsonpath='{.items[0].status.podIP}')
# name of the bridge: br- and the first 12 characters of the network ID
BR=br-$(sudo docker network inspect kind -f '{{.Id}}' | cut -c1-12)
echo $D $BR
# capture in the background, ends after one packet or 8 s:
# -c 1 stop after one packet
# -v verbose: length and header of both IP packets
# udp port 8472 VXLAN only
# and greater 1000 only packets of 1000 bytes or more (our ping, not the health checks)
sudo timeout 8 tcpdump -ni $BR -c 1 -v "udp port 8472 and greater 1000" 2>/dev/null &
sleep 2
# ping with 1000 bytes of data (-s), summary only (-q)
kubectl exec werkzeug -- ping -c1 -s 1000 -q $D | tail -1; waitExpected (addresses, IDs and times differ):
10.244.0.158 br-1eb80005bd1a
rtt min/avg/max/mdev = 0.558/0.558/0.558/0.000 ms
08:25:22.072816 IP (tos 0x0, ttl 64, id 17966, offset 0, flags [none], proto UDP (17), length 1078)
172.18.0.3.54682 > 172.18.0.2.8472: OTV, flags [I] (0x08), overlay 0, instance 1853
IP (tos 0x0, ttl 64, id 26925, offset 0, flags [DF], proto ICMP (1), length 1028)
10.244.1.135 > 10.244.0.158: ICMP echo request, id 15, seq 1, length 1008
Two packets in one: outside, UDP from node to node
(172.18.0.3 → 172.18.0.2:8472, 1078
bytes), inside, the ping from pod to pod (1028 bytes).
The difference is exactly the 50 bytes from the briefing. tcpdump calls
VXLAN “OTV” here (a protocol with the same header), and
instance 1853 is the VXLAN number – in Cilium, the
identity of the sender from Day 14. That way the
receiver knows for the policy who is sending, without looking up the IP.
Note, by the way, flags [none] outside and
[DF] inside: the inner packet must not be fragmented, the
outer one may be.
Save your progress? Sign up for free
Drill 3: Measuring the pod MTU
ping -M do sets the DF bit (“don’t fragment”). With
-s you set the amount of data; on top come 8 bytes of ICMP
and 20 bytes of IP.
# on netz
# 1422 + 28 = 1450: fits exactly
kubectl exec werkzeug -- ping -c1 -M do -s 1422 $D | grep "bytes from"
# one byte more (include the error from stderr with 2>&1)
kubectl exec werkzeug -- ping -c1 -M do -s 1423 $D 2>&1 | grep -E "too large|transmitted"
# where the pod knows this from
kubectl exec werkzeug -- ip route get $DExpected:
1430 bytes from 10.244.0.158: icmp_seq=1 ttl=63 time=0.382 ms
ping: sendmsg: Message too large
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
10.244.0.158 via 10.244.1.250 dev eth0 src 10.244.1.135 uid 0
cache mtu 1450
This is how it should be: the oversized packet never even leaves the
pod, and ping gets a clear error message
(Message too large). The kernel knows the limit from the
route. It gets dangerous when the limit is somewhere
else and nobody says so.
Save your progress? Sign up for free
Drill 4: A service with large responses
An nginx on the control plane serves a small start page and a 300 KB file:
# on netz
cd ~/ndbg/k8s
cat > gross.yaml <<'EOF'
apiVersion: v1
kind: Pod
metadata: {name: gross, labels: {app: gross}}
spec:
nodeName: ndbg-control-plane
tolerations: [{operator: Exists}]
containers:
- name: gross
image: nginx:1.27-alpine
command: ["sh", "-c", "head -c 300000 /dev/urandom > /usr/share/nginx/html/gross.bin && exec nginx -g \"daemon off;\""]
EOF
kubectl apply -f gross.yaml
kubectl wait --for=condition=Ready pod/gross --timeout=180s
G=$(kubectl get pod gross -o jsonpath='{.status.podIP}'); echo $G
# -w prints status, size and total time after the request
kubectl exec werkzeug -- curl -s -o /dev/null -w "%{http_code} %{size_download} Byte in %{time_total} s\n" http://$G/
kubectl exec werkzeug -- curl -s -o /dev/null -w "%{http_code} %{size_download} Byte in %{time_total} s\n" http://$G/gross.binnodeName: ndbg-control-plane– pin the pod to the control plane so the path goes over the overlay;tolerations: [{operator: Exists}]– ignore the control plane’s taint.head -c 300000 /dev/urandom > …– 300,000 random bytes as a file, then start nginx in the foreground.
Expected (IP and times differ):
pod/gross created
pod/gross condition met
10.244.0.14
200 615 Byte in 0.011875 s
200 300000 Byte in 0.004928 s
Both requests take milliseconds. Remember the numbers.
Save your progress? Sign up for free
Exercise
The data center has installed a segment between the nodes that only
lets 1400 bytes through and sends no ICMP messages. On netz
you simulate it in two steps.
First: network cards in real servers split large sends into packets of suitable size themselves (TSO, GSO). The virtual interfaces of the kind nodes instead pass aggregated packets of over 6000 bytes across the bridge. So that the bridge sees real packet sizes, you switch this off on both nodes:
# on netz
# for both nodes: switch off the offloads in the container's network namespace (nsenter -t <PID> -n)
# docker inspect -f '{{.State.Pid}}' process ID of the node container
# ethtool -K eth0 change the offload settings of interface eth0
# tso/gso off kernel splits into MTU-sized packets itself
# gro off do not merge again on receive
for n in ndbg-control-plane ndbg-worker; do
sudo nsenter -t $(sudo docker inspect -f '{{.State.Pid}}' $n) -n ethtool -K eth0 tso off gso off gro off
doneSecond, the bottleneck itself: an nftables rule on the bridge that silently drops VXLAN packets over 1400 bytes:
# on netz
# table bridge underlay table in the bridge family (packets a bridge passes on)
# type filter hook forward chain for everything the bridge sends from port to port
# udp dport 8472 VXLAN only
# ip length gt 1400 total IP length greater than 1400
# counter drop count and drop – without ICMP
sudo nft add table bridge underlay
sudo nft add chain bridge underlay weiter '{ type filter hook forward priority 0; }'
sudo nft add rule bridge underlay weiter udp dport 8472 ip length gt 1400 counter drop
# the same requests as in Drill 4
kubectl exec werkzeug -- curl -s -o /dev/null -w "%{http_code} %{size_download} Byte in %{time_total} s\n" http://$G/
kubectl exec werkzeug -- curl -s -o /dev/null -w "%{http_code} %{size_download} Byte in %{time_total} s\n" http://$G/gross.binExpected (the second time varies between about 5 and 8 s):
200 615 Byte in 0.005400 s
200 300000 Byte in 6.432753 s
The small page: as fast as before. The large file: over a
thousand times slower, but it arrives. Now forget that you know
the rule. Use ping -M do to measure which packet size still
gets through between werkzeug and gross, and
explain why the file arrives at all.
Solution
# on netz
# coarse search: -W1 = wait at most 1 s for a reply
for s in 1000 1300 1350 1400 1422; do echo "$s: $(kubectl exec werkzeug -- ping -c1 -W1 -M do -s $s $G 2>&1 | grep -oE '[0-9]+ received|too large')"; done
# fine search at the limit
for s in 1322 1323; do echo "$s: $(kubectl exec werkzeug -- ping -c1 -W1 -M do -s $s $G 2>&1 | grep -oE '[0-9]+ received|too large')"; done
# why the file arrives anyway
kubectl exec gross -- sysctl net.ipv4.tcp_mtu_probingExpected:
1000: 1 received
1300: 1 received
1350: 0 received
1400: 0 received
1422: 0 received
1322: 1 received
1323: 0 received
net.ipv4.tcp_mtu_probing = 1
The picture of a black hole: 0 received –
no too large. The pod believes in 1450 and
sends out 1351-byte packets that disappear along the way. The limit is
1322 + 28 = 1350 bytes in the pod, plus 50 bytes of
envelope = 1400 on the underlay. That the file arrives
at all is thanks to tcp_mtu_probing = 1: after several
timeouts, TCP tries smaller segments and finds the limit itself – after
seconds. If the value is 0 (the default on many systems), the connection
hangs until the application gives up.
The proof of where the packets end up:
# on netz
sudo nft list chain bridge underlay weiter | grep -o "counter.*"Expected (the numbers differ):
counter packets 227 bytes 656960 drop
Hubble, by the way, does not see these losses: they happen outside the cluster, on the underlay. That is the normal case with MTU problems.
Save your progress? Sign up for free
Challenge
Nobody can change the underlay; the 1400 stays. Make sure that
gross.bin arrives in milliseconds again and an oversized
ping gets an honest error message instead of disappearing – without
touching the nftables rule.
Hint: Cilium has a Helm value MTU for
the MTU of the underlay. The agents only read it at startup.
Solution
# on netz
# set the Helm value, keep all other values (--reuse-values); show only the warning
cilium upgrade --version 1.20.5 --reuse-values --set MTU=1400 2>&1 | grep -E "⚠️"
# restart the agents so they pick up the new MTU
kubectl -n kube-system rollout restart daemonset/cilium
kubectl -n kube-system rollout status daemonset/cilium --timeout=5m | tail -1
cilium config view | grep -E "^mtu"
kubectl exec werkzeug -- ip route | head -1
kubectl exec werkzeug -- curl -s -o /dev/null -w "%{http_code} %{size_download} Byte in %{time_total} s\n" http://$G/gross.bin
kubectl exec werkzeug -- ping -c1 -M do -s 1323 $G 2>&1 | grep "too large"
# counter before and after another request: nothing is added
sudo nft list chain bridge underlay weiter | grep -o "counter.*"
kubectl exec werkzeug -- curl -s -o /dev/null http://$G/gross.bin
sudo nft list chain bridge underlay weiter | grep -o "counter.*"Expected (times and counters differ):
⚠️ You maybe need to restart Cilium pods for configmap changes to take effect
daemonset.apps/cilium restarted
daemon set "cilium" successfully rolled out
mtu 1400
default via 10.244.1.250 dev eth0 mtu 1350
200 300000 Byte in 0.054805 s
ping: sendmsg: Message too large
counter packets 227 bytes 656960 drop
counter packets 227 bytes 656960 drop
Cilium calculates 1400 − 50 = 1350 and writes that into the pods’
routes – including existing ones, once the agents have restarted. The
pod knows the real limit again: it rejects oversized packets itself, TCP
negotiates suitable segments from the start, the counter stays put. The
warning from cilium upgrade is meant seriously: without the
restart, everything stays as it was.
Save your progress? Sign up for free
Checkpoint
# on netz
# pod route, Cilium MTU, request without delay (-m2 = give up after 2 s), ping at the limit, rule active
kubectl exec werkzeug -- ip route | grep -o "mtu [0-9]*"
cilium config view | grep -E "^mtu"
kubectl exec werkzeug -- curl -s -m2 -o /dev/null -w "%{size_download}\n" http://$G/gross.bin
kubectl exec werkzeug -- ping -c1 -W1 -M do -s 1322 $G | grep -o "1 received"
sudo nft list table bridge underlay | grep -c "drop"Expected:
mtu 1350
mtu 1400
300000
1 received
1
Clean up
Day 16 needs the cluster in its normal state: bottleneck gone, offloads on, MTU automatic again.
# on netz
sudo nft delete table bridge underlay
for n in ndbg-control-plane ndbg-worker; do
sudo nsenter -t $(sudo docker inspect -f '{{.State.Pid}}' $n) -n ethtool -K eth0 tso on gso on gro on
done
# MTU=0 means: detect automatically
cilium upgrade --version 1.20.5 --reuse-values --set MTU=0 2>&1 | grep -E "⚠️"
kubectl -n kube-system rollout restart daemonset/cilium
kubectl -n kube-system rollout status daemonset/cilium --timeout=5m | tail -1
kubectl delete pod gross
kubectl exec werkzeug -- ip route | grep -o "mtu [0-9]*"Expected:
⚠️ You maybe need to restart Cilium pods for configmap changes to take effect
daemonset.apps/cilium restarted
daemon set "cilium" successfully rolled out
pod "gross" deleted from default namespace
mtu 1450
The file gross.yaml stays in
~/ndbg/k8s.
Interview note
“Small requests work, large ones hang” or “it works on the same node,
not across nodes” – that is MTU until proven otherwise. Approach:
ping -M do -s <size> between the affected pods to
bracket the limit; 0 received without an error message
means black hole, Message too large means the sender knows
the limit. Then calculate: underlay MTU minus overlay (VXLAN/Geneve 50,
more with IPsec/WireGuard) gives the pod MTU. Bonus points: VNI =
identity in Cilium, tcp_mtu_probing as the explanation for
“slow instead of broken”, and that Hubble cannot see losses in the
underlay.
Enterprise note
In companies, MTU black holes almost always appear at transitions:
VPN and MPLS links, cloud interconnects, firewalls that block ICMP
completely, jumbo frames on one side and 1500 on the other. For clusters
that means: measure the underlay MTU during setup (node
to node with ping -M do), set it explicitly in the CNI
instead of trusting automatic detection, and allow ICMP type 3 code 4
(“Fragmentation needed”) in the firewalls. When switching from VXLAN to
native routing or when enabling encryption, the calculation changes –
then an MTU test belongs in the acceptance testing.