I have created a pod called mypod in alpha namespace with nginx image. And another pod called test with busybox image in default namespace. then I used the command k exec test – nslookup ipaddressofmypod. But this is not working. Do I need to expose mypod as a service for nslookup command to work? the command is working if I expose the pod as a service.
Yes u need to expose the pod internally, use clusterip
Then run this:
Kubectl run test-nslookup --image=busybox:1.28 --restart=Never --rm -it – nslookup <service-name>
since the pod is in a different namespace you need to include the namespace
e.g. nslookup 10-x-x-x.alpha.pod