Fargate service discovery for eureka clients - microservices

We are planning to host our eureka discovery server in the same vpn as our fargate services. What configuration we have to provide in our client container configuration to enable them to seamlessly connect with our discovery server. The discovery server is not hosted on fargate , it is on separate EC2 machine.

You need to point the clients to the Eureka server including the following configuration on the client's application.yml:
spring:
application:
name: <client-name>
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
The EUREKA_URI environment variable need to be set on containers with the Eureka address. The additional localhost URL allows apps run without containers on dev workstations along with a local copy of Eureka (just another boot app).

Related

Register on eureka server on a different machine

I have a microservice architecture in developement mode with an API Gateway running on localhost:8080, some services on localhost:8081...8084 and an eureka server on localhost:8761.
The services register with eureka and everything works fine on my local machine.
I'm trying to deploy the services to azure as single containers. So each service will end up with a unique url.
How can I tell my eureka clients (api gateway and services) where the eureka server is running?
No matter what I try, it will always try to find the eureka server at localhost:8761. These are my settings for the API gateway:
eureka:
instance:
instance-id: ${spring.application.name}:${random.uuid}
client:
service-url:
default-zone: ${EUREKA_HOST:http://localhost:8761}/eureka/
I always end up with this error:
How can I get the services to connect to a eureka server that runs on something like https://example.azurewebsites.net:8761 ? The variable EUREKA_HOST has the correct value since I can use it at other places without problem.

How can i load balance on two eureka server on two different Machines?

I am using Spring Boot and Eureka server for achieving scalability. I have two servers both contain one eureka server and multiple eureka clients.
I want to load balance the API calls b/w clients on one server to another server. lets if A wants to connect to B and B is not available on the local eureka than the eureka should check the client availability on peer eureka server and redirect if available.
I tried making both eureka servers peer of one another here is my configuration
But it is not checking availability on peer eureka server
spring.application.name=dfs-eureka-server
eureka.instance.hostname=192.168.3.63
eureka.client.serviceUrl.defaultZone:http://192.168.3.0:9080/eureka/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=false
eureka.server.renewal-percent-threshold=0.49
eureka.server.enableSelfPreservation=true
eureka.dashboard.path=/eurekaweb
second eureka server
spring.application.name=dfs-eureka-server
eureka.instance.hostname=192.168.3.0
eureka.instance.preferIpAddress=true
eureka.client.serviceUrl.defaultZone:http://192.168.3.63:9080/eureka/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.server.renewal-percent-threshold=0.49
eureka.server.enableSelfPreservation=true
eureka.dashboard.path=/eurekaweb
eureka dashboard
dashboard 1
dashboard 1
please suggest.
keep the below properties common in both the eureka servers and verify.
eureka.instance.appname=eureka-cluster
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true

Configuring Netflix Eureka with Spring Boot Microservices on AWS EC2 (Route 53 + VPC)

We are trying to deploy a set microservices (written in Spring Boot 2) to AWS and we want to enable service discovery using Eureka.
The Eureka server is running on Tomcat 9 on a Linux EC2 instance. The Eureka dashboard is reachable, but clients will not register. Clients register successfully on localhost, however.
Due to resource constraints, we are unable to use EIPs for the microservices. We are using Route 53 in conjunction with a Virtual Private Cloud for routing.
I found some mentions of this setup being mostly compatible, but no instructions:
Register VPC Eureka node in Route53 instead of EIP
Service Discovery - Microservices on AWS
Here are our Eureka server properties:
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
# below are prod environment variables
eureka.us-east-1.availabilityZones=us-east-1a
eureka.serviceUrl.us-east-1a=https://eureka.mydomain.com/
eureka.shouldUseDns=true
eureka.eurekaServer.domainName=eureka.mydomain.com/
eureka.eurekaServer.port=8081
eureka.eurekaServer.context=svc
eureka.datacenter=cloud
Here are our Eureka client properties:
eureka.us-east-1.availabilityZones=us-east-1a
eureka.serviceUrl.us-east-1a=https://eureka.mydomain.com/
eureka.shouldUseDns=true
eureka.eurekaServer.domainName=eureka.mydomain.com/
eureka.eurekaServer.port=8081
eureka.eurekaServer.context=svc
eureka.datacenter=cloud
Any help with our situation would be very much appreciated! Please let me know if you need more information.
It seems you are running Eureka on the port 8081. Eureka server usually runs on port 8761.
Have you created Route 53 endpoints (TXT Records) Ref: https://github.com/Netflix/eureka/wiki/Deploying-Eureka-Servers-in-EC2
Eureka Clients need to have below configuration:
https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html
`
#Bean
#Autowired
#Profile("!default")
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
config.setHostname(info.get(AmazonInfo.MetaDataKey.publicHostname));
config.setIpAddress(info.get(AmazonInfo.MetaDataKey.publicIpv4));
config.setNonSecurePort(appPort);
config.setDataCenterInfo(info);
return config;
}
`
Hope this helps.

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/

JHipster micro-services unable to register properly to Eureka on AWS

I have a Spring Cloud application working well on AWS.
I decided to add JHipster generated micro-services (the JHipster gateway and UAA).
Both of these services register to an existing Eureka Server, like all the previous ones.
Things work fine on a local machine, or running in Docker containers deployed on a EC2 instance on AWS.
However, when deploying on different EC2 instances, the JHipster generated services are not registering correctly. The Eureka UI displays :
Application AMIs Availability Zones Status
HELLO-SERVICE ami-809f84e6 (2) eu-west-1b (1), eu-west-1a (1) UP (2) - i-02eg07053a672ea37 , i-083c2f2204d01f4ba
UAA n/a (2) (2) UP (2) - 97b39345fb59:uaa:9999 , ga6831e52701:uaa:9999
"HELLO-SERVICE" is a simple spring boot app. Eureka displays AWS information, and links it to a private ip/port which is working.
"UAA" is generated by Jhipster. Eureka is missing AWS information for this service, and links it to a 172.17.x.x.x address which is not working.
What bothers me is that both services share the same eureka configuration files :
eureka:
datacenter: cloud
instance:
preferIpAddress: true
client:
healthcheck:
enabled: true
registerWithEureka: true
fetchRegistry: true
region: eu-west-1
preferedSameZone: true
availabilityZones:
eu-west-1: eu-west-1a,eu-west-1b
serviceUrl:
eu-west-1a: http://[eurekainstance]:8761/eureka/
eu-west-1b: http://[eurekainstance]:8761/eureka/
Why would a JHipster generated app and a simple Spring Boot app behave differently while sharing the same configuration ?
I have run out of ideas, any help would be much appreciated!
I'll anwser my own question in case it's useful to someone.
The issue had nothing to do with JHipster or AWS, but with Docker.
Adding an EurekaInstanceConfigBean solved it:
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inet) {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inet);
AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
config.setDataCenterInfo(info);
info.getMetadata().put(AmazonInfo.MetaDataKey.localHostname.getName(), info.get(AmazonInfo.MetaDataKey.localIpv4));
config.setHostname(info.get(AmazonInfo.MetaDataKey.localHostname));
config.setIpAddress(info.get(AmazonInfo.MetaDataKey.localIpv4));
config.setNonSecurePort(port);
return config;
}
See the documentation for more information.

Resources