Interview Prep/Networking/Performance, MTU, Latency & Tools

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 →

  1. Run kubectl debug -it pod/web --image=nicolaka/netshoot --target=web -- bash
  2. Inside run tcpdump -ni eth0 port 8080 -w /tmp/c.pcap
  3. Copy out with kubectl cp web:/tmp/c.pcap ./c.pcap -c debugger-xyz
  4. Alternatively use kubectl sniff (krew plugin) to stream into Wireshark
  5. Capture on the node with tcpdump -i any to 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.

All Networking questions Roadmap: Networking for DevOps

More on Performance, MTU, Latency & Tools