Tcpdump from a pod for cluster in kubernetes setup (In Minikube setup)

8/22/2018

I am new to kubernetes. The whole setup I have configured in Minikube. I am not sure it should different than any other kubernetes setup.

I have created a POD in my setup and an spring boot application is running inside on 8080 port and this service to expose to Cluster on 20080 port.

I am running another pod inside the cluster where tcpdump is running. I have requirement to dump the HTTP packets hitting the cluster on 20080. Please let me know how I can access Cluster interface from the tcpdump pod.

I tried google and tried using Cluster IP directly from the POD,but it didn't work.

-- nagendra547
kubectl
kubernetes
minikube
networking

1 Answer

8/22/2018

The POD that is running tcpdump can only see its own netns, except you run the POD with the hostNetwork: true option.

So maybe what you can do is running POD with hostNetwork: true option, then use tcpdump to monitor the host's physical interface to grab the network packages on port 20080. Also you can monitor the network interface of the POD that's running the spring boot, if you can find the POD's network interface, which depends on the network configurations.

-- Kun Li
Source: StackOverflow