keijack / python-eureka-client

A eureka client written in python. Support registering your python component to Eureka Server, as well as calling remote services by pulling the the Eureka registry.
MIT License
187 stars 44 forks source link

Register with name rather than IP #78

Closed mng77 closed 1 year ago

mng77 commented 1 year ago

Hi, is there a way to have a python client register with the Java Eureka registry using the instance name? The java/spring services list in the registry with a name and are accessible, but the python ones using this library display with the IP and I then get an error via the gateway when trying to access. - Failed to resolve 'testservice-cf78478d5-brx52' [A(1)] after 2 queries. Either that or I am missing some configuration somewhere and need to have both java and python services in the stack. any help appreciated. thanks!

keijack commented 1 year ago

Do you set app_name in the init method?

mng77 commented 1 year ago

Yes,

eureka_client.init( eureka_server=self.server_url, app_name=self.app_name, instance_port=instance_port, renewal_interval_in_secs=10 )

What I see on the eureka page for a java service e.g gateway is gateway-f4d6dd9f7-4z6nl:gateway:8760, but for a python app this shows as [10.11.12.13:testservice:50999] and python services don't seem to be dynamically discovered through the gateway, only way I got it to work was if I specify the actual route in the gateway. am I possibly missing some options somewhere? thanks

keijack commented 1 year ago

You may set instance_host, this component now will not find the hostname automatically. And where is your component run at? In a docker environment or K8S?

mng77 commented 1 year ago

I set instance_host=socket.gethostname() but that didn't make a difference. Im deploying out to openshift so K8s. A new java tool can be successfully deployed and registers/accesses correctly by pointing at the registry host e.g http://registry.server.name:8761/eureka, using that same line in the python client for eureka server though leads to a 503 error as it cannot connect. its all in the same area as well