How to track a packet in order to list the source pod ip and the destination pod ip

1/13/2018

How can I obtain the final destination pod ip to which a request is routed in a Kubernetes network with the use of service? Is it possible to hook with netfilter to obtain client pod ip and server pod ip to which the packet will be routed. Will Kube proxy list all the incoming requests?

-- user3946910
kubernetes
networking

1 Answer

1/13/2018

You can use -o jsonpath to get information you need from the service and endpoints objects.

To get pod's IP which service is pointing to:

kubectl get endpoints <service_name> -o jsonpath='{.subsets[].addresses[].ip}'

To get service IP:

kubectl get service <service_name> -o jsonpath='{.spec.clusterIP}'
-- nickgryg
Source: StackOverflow