How do you capture traffic from a Kubernetes pod without changing the image?
IntermediateScenarioPerformance, MTU, Latency & Tools
Answer
Situation read → Use an ephemeral debug container sharing the pod's network namespace.
What I'd do →
- Run
kubectl debug -it pod/web --image=nicolaka/netshoot --target=web -- bash - Inside run
tcpdump -ni eth0 port 8080 -w /tmp/c.pcap - Copy out with
kubectl cp web:/tmp/c.pcap ./c.pcap -c debugger-xyz - Alternatively use
kubectl sniff(krew plugin) to stream into Wireshark - Capture on the node with
tcpdump -i anyto see the CNI path
Why → A shared network namespace gives full visibility without modifying the application image.
Interview tip → Say production images shouldn't carry tcpdump.
More on Performance, MTU, Latency & Tools
Latency, bandwidth and throughput: what is the difference and why does it matter?BeginnerWhen do you use ping, traceroute and mtr?BeginnerWhat is MTU and what is the usual value?BeginnerHow do you check what is listening on a port and who is connected?BeginnerHow do you measure where time goes in a slow HTTP request?BeginnerWhat does tcpdump do and what are the first filters you use?Beginner