spring cloud discovery service - registering secure clients - healthCheckUrl - spring-boot

I have all clients (eureka instances) running with https. I have configured my eureka clients as mentioned in https://cloud.spring.io/spring-cloud-netflix/2.2.x/reference/html/#registering-a-secure-application
Everything in the config shown below works except the port information. Note that the config is clearly missing port information for all URLs, viz, statusPageUrl, healthCheckUrl and homePageUrl.
eureka:
instance:
nonSecurePortEnabled: false
securePortEnabled: true
**statusPageUrl: https://${eureka.hostname}/info**
**healthCheckUrl: https://${eureka.hostname}/health**
**homePageUrl: https://${eureka.hostname}/**
client:
serviceUrl:
defaultZone: ${EUREKA_SERVER}
healthcheck:
enabled: true
Since I have configured random port, I cannot hard code the port information in above urls. Could anyone please help me on this?
server:
port: 0

Related

What is the use of "wait-time-in-ms-when-sync-empty" in Spring Eureka Server?

I was going through a tutorial and I came across with this config in .yml file.
eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0
Here, what exactly is the purpose of "waitTimeInMsWhenSyncEmpty"? Also what does "fetchRegistry" flag say?
Thank you.
eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0
Basically above three lines tells:
this instance to not register itself with the Eureka instance it finds, because that instance is.. itself.
Source :Spring Doc
Below are the individual statement level meanings:
Configuration tells eureka(client) to gets the registration information from the eureka server registry, the default is true
eureka:
client:
fetchRegistry: false
Configuration tells when the eureka server is started, you cannot wait for the instance registration information from the peer node. How long should it wait?source
eureka:
client:
server:
waitTimeInMsWhenSyncEmpty: 0
Usage : By default euraka server could act as both client and server.This is useful when we run multiple eureka servers to face SPOF issues.In this case , eureka could register both other microservice instances and naming server instances.

Spring Boot Eureka - Faster offline detection

I am using Spring Boot with Eureka and it works really good. But since a few hours, I wanted to detect offline Eureka instances/clients more quickly and I found no good documentation about Eureka's configuration properties. And I'm not even sure if it's possible because Eureka seems to presume that clients send their updates every 30 seconds.
I started to deactivate self-preservation mode and to increase the speed of renewal and interval updates and lower expiration durations but my Eureka server still needs two minutes to discover its offline clients.
After changing the renewal percent threshold the Eureka server didn't remove offline clients ever.
Is there any way to detect offline Eureka clients more quickly?
Server configuration:
eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
enableSelfPreservation: false
eviction-interval-timer-in-ms: 10000
response-cache-update-interval-ms: 5000
Client configuration:
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
healthcheck:
enabled: true
instance:
lease-renewal-interval-in-seconds: 5
lease-expiration-duration-in-seconds: 15
edit:
Even health check url is not called more often. It is still called every 30 seconds.
Did you check Ribbon configuration. Ribbon can cache servers configuration upfront during startup and make use of it when Eureka-sever is down. Please check if ribbon is enabled on eureka-client app
The correct option to change the schedule was:
eureka.client.instance-info-replication-interval-seconds

Configure consul health check to spring boot actuator '/health'

For a microservice that I have been working on, I created a custom health check class extending AbstractHealthIndicator and able to get the output in
http://localhost:8080/actuator/health
But when I register the service with consul, the health check status is failing.
Tried to configure the actuator url with consul health check asspring.cloud.consul.discovery.health-check-url= http://localhost:8080/actuator/health in bootstrap. But it is still failing with error Get http://localhost:8566/actuator/health: dial tcp 127.0.0.1:8566: connect: connection refused
If I try with health-check-path: /actuator/health, it is not taking this path at all and defaulting to http://QINDW062.it.local:8566/my-health-check.
Any suggestions?
Edit:
You need to set a property in your configurations file (application.yml for example) pointing to your health check endpoint:
spring:
cloud:
consul:
discovery:
healthCheckPath: /actuator/health
You can also decide the time interval for the health check (how often Consul will call the health check) with the following property:
spring:
cloud:
consul:
discovery:
healthCheckInterval: 20s

Spring boot Eureka in docker swarm registering wrong internal docker ip's

Docker nodes are registering with inter ip's in springboot-eureka
My conf is as follows
1. Spring-boot eureka deployed to swarm (1 node)
2. Created spring-boot client containers (2nodes) and registering with eureka
The above containers are deployed as separate deployments, and the client conf is as follows
eureka:
instance:
prefer-ip-address: true
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://eureka-server-address/eureka/
healthcheck:
enabled: true
Spring:
cloud:
inetutils:
ignored-interfaces:
- eth0
- eth1
- eth2
- eth3
- lo
the ip's come as 172.1.0.1 instead of real-external ip's. and docker containers fail to connect each other with the real ip's.
docker-compose
network_mode: bridge
Update:- The swarm functions in a different way we think it would.
1. The ip's are docker's internal network distributions which is what we know
2. The entire swarm itself is not a bignetwork to work internally (new lesson)
3. We need to create a new network inside swarm for the containers to talk to each other (known + new lesson ..yes got confused)
For people who are searching for an answer, Please research for docker swarm networking options and create 2 networks 1 for internal and 1 for external traffic and assign them to the containers in your docker-compose). I was able to get it work for my POC but it tend to be hard for going to do in the enterprise scale.

Can I Enrol One Micro services at 2 Different eureka

I don't know whether it is possible or not. I want to know whether I can enroll one microservice at two different eureka server at once.
I have one MS let say API-GATEWAY:
I want to enrol it on two different eureka registry server running on 8761 and 8762.
for that I write:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/ , http://localhost:8762/eureka/
registry-fetch-interval-seconds: 1000
instance:
hostname: api-gateway
prefer-ip-address: true
lease-renewal-interval-in-seconds: 5000000
lease-expiration-duration-in-seconds: 5000000
First up all tell me is it possible or not?
If yes, what property should I use to achieve the objectives?
You can have only one defaultZone. You need peer replication. So that your 8761/eureka is synchronized with 8762/eureka. When the application is registered to 8761 it is also available in 8762. To do this see #spencergibb answer here.

Resources