I have a Kubernetes service (java application) that needs to access a database service on the host machine via http localhost:port
Is it possible to give the service access to the host machines network, and how?
This is a bit of an odd design since typically you either run your database outside the cluster or in the cluster but within the Kubernetes network space. However, your pods should be able to access your host network stack using the host's IP address or for example, the IP address configured on the machine's ethernet interface.
You won't be able to access it through localhost
because that will resolve to 127.0.0.1
in the pod which means the local within the Pod.
I hope it helps!