DNS lookup of external address in Quarkus application returns loopback address

125 Views Asked by At

I want to loopup the ip addresses of a headless kubernetes service to access each pod. When testing it on the very pod with getent hosts my-headless-service it returns the 2 expected ips. When I call InetAddress.getAllByName("my-headless-service") in my Quarkus application that runs on the same pod, I get the loopback address[localhost/127.0.0.1]

Are there any pit falls which I am not aware of when resolving a host name with Java?

1

There are 1 best solutions below

0
Herr Derb On BEST ANSWER

After wasting some time I discovered that quarkus has disabled name resolving by default due to security reasons. Setting quarkus.naming.enable-jndi=true resolves the problem and the lookup works as expected using InetAddress.

See -> Disabling JNDI by default https://groups.google.com/g/quarkus-dev/c/bp1wVF1yLXE