Photo by Cesar Carlevarino Aragon on Unsplash

Capture tcpdump with ksniff and wireshark from Kubernetes

Rocky Chen
CodeX
Published in
5 min readMar 3, 2023

--

Tcpdump is a powerful command-line packet analyzer tool for Unix/Linux operating systems and it uses the libpcap library to capture network traffic. Therefore it is very useful when troubleshooting network issues.

Tcpdump in Kubernetes

In the world of Kubernetes, there are many different ways to deploy and run applications, such as using containers, pods, services, and more. Tcpdump can be used to capture network traffic between these components, helping to identify network issues and diagnose problems.

There are several ways to run tcpdump in Kubernetes clusters. One approach is to deploy a container with the tcpdump tool as a sidecar alongside the application container in a pod. Then the container can capture network traffic on the same network interface as the application container, allowing it to see all the traffic that the application is generating and receiving.

Another approach is to use the kubectl command-line tool to execute a TCPdump command on a specific pod or set of pods. This approach requires access to the Kubernetes API server and the necessary permissions to execute commands on the pods. Unfortunately, lots of containers don’t include the tcpdump tool by default and it is inconvenient to install it to containers or mostly forbidden.

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Rocky Chen
Rocky Chen

Written by Rocky Chen

SRE | Cloud Engineer | AWS Certified Solutions Architect – Professional

No responses yet