Eureka service discovery not working in Azure - spring

I have 2 micro-services that register with Eureka. I run the projects locally and call one micro-service from another using Feign & Ribbon and everything works fine.
However when I deploy everything to Azure it no longer works.
I can see the services registered in eureka dashboard but when I click on a particular service I get an url like this http://100.79.xxxx.xx:xxxx and after loading for a while I get a connection timeout. Same happens in code when one micro-service calls the other through Eureka.
I also added this setting to eureka clients but it didn't help:
eureka.instance.prefer-ip-address: false
It seems that the IP addresses of services instances are not reachable.
Is there a way to make Eureka work on Azure? Thanks for your help.

Related

Stop specific instance to register Eureka

I have a eureka server running on test server and multiple services registers from test server to this eureka server.
Now problem is sometimes developers also connect their local microservice instance for some service to eureka. Due to this it shows multiple instances for that service on eureka and load balancer starts sending request to local servers as well from feign client. That causes issues in testing as test server is not able to connect local developers machine in feign client calls.
I instructed developers to set eureka.client.register-with-eureka=false from local but still if someone connects how can I stop that. Is there a way that eureka server registers only from specific IP (test server ip)? Or any other solution to prevent this problem?
For the services that you don;t want them to register, remove #EnableDiscoveryClient from the services. #EnableDiscoveryClien lives in spring-cloud-commons and picks the implementation on the classpath. This will stop your services from getting discovered but then you won;t be able to make the Feign calls to other services and take the benefit of load balancing your calls.

Spring boot micro service Deployment

I am new to Micro services architecture.. I want know if it is required to deploy all Spring boot micro services in the same local network ..? As Eureka Discovery service uses Private/Internal IP Address for Registration , i am unable to call a services from another service deployed in different local network...
Please let me know how micro services deployed across multiple Sub nets should communicate each other in this case
or is there a way to tell eureka to use only public IP Address..?
Not sure if this would help, but by default, your eureka client will try to connect to the default localhost:8761 where the eureka discovery server should exist.
In case you have a different location for your discovery-service you can use the following in the application.properties file in your client services.
eureka.client.service-url.defaultZone=http://{address}-{port}/eureka

Programmatically find Eureka server host and port

I want to setup Eureka server for service registry and erueka clients that will get access rest api using the service registry from Eureka server. But we use mesos as our container management system and when we start the Eureka server we will not know which host and port it is running on. So there is an api that we can use that gives us the complete url where Eureka server will be running. Now all the examples for Eureka client that I have seen have hard coded the Eureka server in the config file. Is it possible for Eureka clients to use that api and get the url for Eureka server.
FYI: we are using spring boot and have our own DC and are not on any cloud
I think I found the answer but if someone can confirm that will be great. I need to create my own EurekaClientConfigBean and override the following methods:
public void setEurekaServiceUrlPollIntervalSeconds(int eurekaServiceUrlPollIntervalSeconds)
List<String> getEurekaServerServiceUrls(String zone);

Problems setting up Zuul proxy server with Eureka discovery

I am trying to set up a zuul proxy server which will act as a gateway service for other apis in my microservice architecture.
So far all the tutorials that I have come across have the discovery client and zuul proxy set up in different gradle modules while I am trying to set them up in the same gradle module.
I have defined the routes and can see that my services have been successfully registered in the eureka dashboard.
I have also verified that I can ping the services using a discovery client from my gatekeeper service but whenever I try to access the services from the URL, I get
"Load balancer does not have available server for client:xyz"
exception.
Can somebody please help me setting this up?

how to have a turbine cluster for each eureka app in spring boot?

I am trying to obtain an "autoconfiguration" of turbine clusters from my eureka server.
registered on the eureka server I have configured 3 apps: app1, app2, app3.
registered on the eureka server there are also a zuul proxy and a turbine monitor.
i can access the three apps via zuul correctly, i can see all of the hystrix.stream of each app correctly.
I have configured a single turbine cluster 'default' and I can see the merged turbine stream (and the dashboard) of all the three apps from the dashboard without issues.
my turbine application.properties looks like this:
eureka.client.serviceUrl.defaultZone=http://localhost:33210/eureka/
turbine.app-config=app1,app2,app3
turbine.cluster-name-expression=new String("default")
what I can't seem to do is to distinguish the turbine streams to avoid mashing up all the hystrix commands between the three apps in the dashboard.
what I would like to have as a result is the possibility to put
/turbine.stream?cluster=app1
/turbine.stream?cluster=app2
/turbine.stream?cluster=app3
where cluster matches the eureka name of each app, and obtain three different dashboards. I thought by documentation that removing by the cluster-name-expression the default would be the appName instead of the static 'default', but it doesn't happen.
what did I get wrong?
property name should be like
turbine.clusterNameExpression= new String("default")
to have different cluster for each stream... assuming you even have different management port enabled on each service in eureka, i.e. 51511 and 51521 is for service endpoints and 51512 and 51522 is for management endpoints.
turbine.instanceInsertPort=false
turbine.appConfig=service1,service2
turbine.aggregator.clusterConfig=SERVICE1,SERVICE2
turbine.instanceUrlSuffix.SERVICE1=:51512/hystrix.stream
turbine.instanceUrlSuffix.SERVICE2=:51522/hystrix.stream
turbine.clusterNameExpression= new String("default")
this worked out for me.
I only replaced
turbine.cluster-name-expression='dafault'
with above and it worked like a miracle for me.

Resources