Is there a way to access a pod by its hostname? I have a pod with hostname: my-pod-1
that need to connect to another pod with hostname: my-pod-2
.
What is the best way to achieve this without services?
I am not sure what do you mean exactly by "accessing" a pod but if you need to programmatically make some HTTP calls to some pods, you can do something similar to what this libcluster nodejs library does.
It's hackish but basically it works with enquiring list of endpoints (pod's IPs) from Kubernetes APIs.
Through your description, Headless-Service is you want to find. You can access pod by accessing podName.svc
with headless service.
OR access pod by pod ip address.