I have number of statefulsets PODs and they are not replica of each other. My application register service on the hostname of the pod and other services try to reach the service based on hostname. It works fine with headless service but application logic cannot be changed as it reads the hostname of POD and unfortunately I have to use that.
I have following scenario:
[test@shard1-0 ~]$ nslookup shard2
Server: 10.96.5.5
Address: 10.96.5.5#53
Name: shard2.default.svc.cluster.local
Address: 10.244.0.50
[test@shard1-0 ~]$ nslookup shard2-0
Server: 10.96.5.5
Address: 10.96.5.5#53
** server can't find shard2-0: NXDOMAIN
[test@shard1-0 ~]$
Is there a way that shards can resolve using the hostname of POD name ?and can reach each other as application is registered based on pod hostname.
Just to clarify if we are able to resolve this problem, we also need to expose these pods externally. I think for that I can use that and hopefully it will work: How to set hostname for kubernetes pod in statefulset