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?
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}'