Stop specific instance to register Eureka - microservices

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.

Related

Handle eureka client disconnection on the eureka server

I am trying to understand Spring Cloud's Eureka client/server mechanism. I have built a very basic server and client app using just the #EnableEurekaServer and #EnableDiscoveryClient annotations respectively. I am able to see the registered clients in the eureka dashboard.
I was wondering if there is any way to get notified on the server whenever any client disconnects(goes down).
Example: I have a server and two clients (client1 and client2) registered on it.
Now if for any reason client2 goes down, can I get any event on the server so as to perform some tasks (cleanup tasks, calling some APIs etc).
Is this possible using eureka or any other library which might plug into eureka clients' lifecycle?

why consumer has to register with eureka server?

I am currenly learning microservices. I have two services Service A and Service B. Service A registered with Eureka server. Service B is calling Service B via Eureka server to get the response. My question is
why Service B has to register with Eureka service in order to call Service A?
Service B can get the Service A url and portno through service discovery from Eureka server. What is the significance of Service B to register with Eureka server?
Typically in Microservices architecture, we have a lot of small applications running independently together, and ofcourse they will all have their own URLs and ports.
In that scenario, it would be very cumbersome to maintain all these microservices to run in synchronization, and more importantly, with monitoring. This problem will increase manifold when we start implementing load balancers.
To solve this issue, we need a tool that will monitor and maintain the registry of all the microservices in the ecosystem.
That's why Eureka server acts as directory and service discovery system to make sure they is no direct binding between services and it make sure to have health check for those services.

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?

Eureka service discovery not working in Azure

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.

Spring Cloud Eureka Connecting to a Secured Service

I'm attempting to establish a discovery server with spring cloud Eureka which needs to connect to a secured client. I understand how to secure the Eureka sever itself - that isn't the issue. The issue is in the other direction - how to get Eureka to successfully communicate with a client service that itself is secured.
In other words; I have a discovery client that registers itself with Eureka. That client implements http basic authentication. It can and does successfully register itself with the discovery service, however when I attempt to utilize that service with a lookup to the discovery service, I get authentication failures (on the client service itself) which of course makes sense because I haven't specified any credentials anywhere and have no idea how to do so. Any assistance would be greatly appreciated.
Guessing from your tags you are using spring-cloud.
When you use your service (with RestTemplate or Feign or manually looking up and interacting with it), your request has nothing to do with Eureka. Eureka only provides you information about your services whereabouts. Once you (or some undelying logic) obtained the address of the service, you are directly communicating with it.

Resources