Interview Prep/Networking/Containers, Kubernetes, IPv6 and packet captures

You need to capture traffic from a Kubernetes pod whose image has no shell or tcpdump.

IntermediateTroubleshootingContainers, Kubernetes, IPv6 and packet captures
Answer

Likely causes → Distroless or minimal images don't include tools, and you shouldn't add them. The pod's network namespace is shared by all containers in the pod, so you can attach a tool container to it.

Diagnose →

# ephemeral debug container sharing the pod network namespace
kubectl debug -it pod/myapp-7d9f -n prod --image=nicolaka/netshoot --target=app -- tcpdump -ni eth0 -w /tmp/cap.pcap port 8080
# or from the node
crictl inspect <container-id> | grep -m1 '"pid"'
sudo nsenter -t <pid> -n tcpdump -ni eth0 port 8080 -w /tmp/cap.pcap

Fix → Copy the capture out for analysis: kubectl cp prod/myapp-7d9f:/tmp/cap.pcap ./cap.pcap -c <debug-container-name>, or stream it live: kubectl debug ... -- tcpdump -ni eth0 -U -w - > cap.pcap.

Prevent → Allow kubectl debug through RBAC for on-call engineers only, and document the procedure in the runbook.

All Networking questions Roadmap: Networking for DevOps

More on Containers, Kubernetes, IPv6 and packet captures