Programmatically find Eureka server host and port - spring-boot

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);

Related

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

Spring Loadbalancer Configuration without a discovery server

I am currently working on a POC about client side load balancing. 
I thought to use Spring Cloud Loadbalancer for that. But unlike Netflix Ribbon, I could not find a way to configure Spring Cloud Loadbalancer to work without a discovery server such as Eureka. 
Please could you let me know if there is a way to configure it to work without a discovery server (just by giving a list of ip addresses) .
Thanks

Eureka service can not be found when running in Docker Container

So I have a very simple setup of a Eureka server and one service. When running locally with tomcat everything works perfect. However, when I run these locally in docker containers.. the service registers to the eureka server but whenever I make the http calls via FeignClient it says there is no load balance for the service (Cant find service). It acts as if the service can find the eureka server but the server can not find the service. And once again, only broken when runnind in docker containers.
My Eureka server
spring.application.name=eureka-service
server.port=8761
eureka.client.fetch-registry=false
eureka.client.register-with-eureka=false
My Service
spring.application.name=users-service
server.port=8081
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=false
eureka.instance.prefer-ip-address=true
eureka.client.service-url.defaultZone=http://**EurekaServerIp**:8761\eureka
I was able to fix it by making sure my Eureka server, Services and Zuul gateway were running on the same (Overlay) docker network. However, I now need to find a way to only make the zuul gateway accessible from outside the network, and protect all the services.
EDIT: I found a very easy way to expose gateways and hide services with docker --link, here is a good article https://exampledriven.wordpress.com/2016/06/24/spring-boot-docker-example/

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?

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