My Spring Eureka instance always shows test in the Environment field at System Status Panel. What does "test" mean?
I didn't find none about this in the documentation of Spring Eureka.
Related
I know I can set up LDAP properties in my application.profile in Spring Boot like:
spring.ldap.username=user
spring.ldap.password=pass
spring.ldap.urls=ldap://my.domain.com
and Spring actuator /health endpoint will pick up this setting automatically and display its health status.
But what if I use two different LDAPs? How do I set them both up in application.properties so that /actuator/health will pick them both up and display their health status?
I would like to do this from within applicaiton.properties rather than providing custom health indicators classes to do the job.
The microservices are getting registered to Eureka with the pod name as hostname, this causing UnknownHostException, when the Zull API gateway trying to forward the request to the service.
The complete setup working fine with the docker-compose, the issues are happening when I am trying to use the Kubernetes.
For example, the order microservice running with the pod name as "oc-order-6b64576f4b-7gp85" and the order microservice getting register to to Eureka with "oc-order-6b64576f4b-7gp85" as the hostname. Which is causing
java.net.UnknownHostException: oc-order-6b64576f4b-7gp85: Name does not resolve
I am running just one instance of each micro-services as a POC and one instance of the Eureka server. How to fix, how micro-service can register them self with the right hostname.
I want to use the Eureka as discovery service as it is well integrated with spring boot and I do not want to do code changes for Kubernetes deployment.
Add the below property to your spring properties file in each service project:
eureka.instance.hostName=${spring.application.name}
or (if you want a different name than the spring application name)
eureka.instance.hostName=<custom-host-name>
Spring boot will now register with the provided hostname in Eureka
For a project I am using Spring Eureka. It works great with Spring boot 1.5. I want to upgrade to Spring boot 2. I see that with Spring boot 2 the health endpoints have moved. Does eureka know how to handle this change?
Out of curiosity, when spring registers to eureka does it pass on what the health url is so that eureka knows where to contact the health url?
I did the spring boot version upgrade recently. Eureka works fine with spring boot 2.
Does eureka know how to handle this change?
Yes, based on below configuration it will look for the default /actuator/health endpoint.
/**
* Default prefix for actuator endpoints
*/
private String actuatorPrefix = "/actuator";
private String healthCheckUrlPath = actuatorPrefix + "/health";
So, if we have actuator endpoint enable it tries to connect to the given endpoint for health check.
when spring registers to eureka does it pass on what the health url is so that eureka knows where to contact the health url?
Yes, we can provide the health check URLs while registering client to eureka server. In that case it will always do the health check from provided endpoint.
Here goes the property we can use to set the same-
eureka.instance.health-check-url-path= HEALTH_CHECK_URL_PATH
OR,
eureka:
instance:
healthCheckUrlPath: HEALTH_CHECK_URL
In Consul, the health status configured in SpringBoot applications can be viewed.
Can anyone know let me know what other metrics (Other than health) can be seen in Consul through Actuator ?
Or can we make Consul to pull/invoke any services/URLs of a services so that the response could be viewed in consul ?
Consul is using health endpoints to determine whether service instance is healthy. If you want custom health status which considers some custom metrics you should implement HealthIndicator interface.
You can expose more information in health api by setting management.security.enabled=false in application.properties
In this case you'll see something like this in consul admin UI for your service
HTTP GET http://192.168.0.102:8080/health: 200 Output: {"description":"Composite Discovery Client","status":"UP","discoveryComposite":{"description":"Composite Discovery Client","status":"UP","discoveryClient":{"description":"Composite Discovery Client","status":"UP","services":["application","consul"]}},"diskSpace":{"status":"UP","total":499963170816,"free":341478899712,"threshold":10485760},"consul":{"status":"UP","leader":"127.0.0.1:8300","services":{"application":[],"consul":[]}},"hystrix":{"status":"UP"}}
You can configure health URL to different endpoint. For instance if you specify spring.cloud.consul.discovery.healthCheckPath=/health2 then your spring-boot instance will register with the following json (see log snippet below):
Registering service with consul: NewService{id='application', name='application', tags=[], address='192.168.0.102', port=8080, enableTagOverride=null, check=Check{script='null', interval='10s', ttl='null', http='http://192.168.0.102:8080/health2', tcp='null', timeout='null', deregisterCriticalServiceAfter='null', tlsSkipVerify=null, status='null'}, checks=null}
I am rewriting a Spring MVC system.
The system is something like this in simple:
[Gateway<->Backend Services<->Databases], where Gateway is a controller simply for authentication and forwarding the requests to Backend services.
The Backend services will be refactored to micro-services. I will use Eureka service to do registration for each of them. So eventually the architecture will be: [Gateway <-> Eureka <-> Backend micro-services <-> Databases]. The Gateway will lookup the registries from Eureka server and call the micro services.
However, the Gateway is not a spring boot application(and will NOT be rewritten as Spring boot), thus I don't believe Spring's eureka features (#EnableEurekaClient , DiscoveryClient, ect.) can be adopted easily as the examples do. Actually I tried adding the eureka client annotation to Gateway's controller, which caused my application collapsed.
Moreover, Ribbon is needed in the Gateway for client side loading balancing. But the same concern is as above.
//Update on 1st Nov.
I have set up an Eureka server and a client, both of which are written in spring boot. I am using these two application for my Spring MVC testing. The server and client are running well.
Server's configuration application.properties is as below
server.port=8761
spring.application.name=service-itself
eureka.client.service-url.default-zone=http://localhost:8761/eureka/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=false
logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF
client's is as below: application.yml
spring:
application:
name: say-hello
server:
port: 8090
eureka:
client:
service-url:
defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/
When accessing the Eureka dashboard localhost:8761, I can see that client has been registered.
For my Spring MVC gateway, as it is not a Spring boot project, so I copied the example to my project simply for testing whether it can connect to the Eureka server and retrieve the registered the instance of "say-hello" client. Unfortunately, it cannot do so with saying "Cannot get an instance of example service to talk to from eureka" which is printed at line 76 in the example class.
Here is the eureka-client.properties placed in gateway's classpath. I can confirmed that the Client class is reading the config file.
eureka.name=gatewayEurekaClient
eureka.vipAddress=say-hello
eureka.port=8761
eureka.preferSameZone=true
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.serviceUrl.default=http://localhost:8761/eureka
eureka.serviceUrl.defaultZone=http://localhost:8761/eureka
Moreover, this is the debug information when new DiscoveryClient(applicationInfoManager, clientConfig); is being executed
instanceInfo InstanceInfo (id=234)
actionType null
appGroupName "UNKNOWN" (id=246)
appName "GATEWAYEUREKACLIENT" (id=247)
asgName null
countryId 1
dataCenterInfo PropertiesInstanceConfig$1 (id=248)
healthCheckExplicitUrl null
healthCheckRelativeUrl "/healthcheck" (id=253)
healthCheckSecureExplicitUrl null
healthCheckUrl "http://A156N7AB89AXNZQ:8761/healthcheck" (id=254)
homePageUrl "http://A156N7AB89AXNZQ:8761/" (id=255)
hostName "A156N7AB89AXNZQ" (id=256)
instanceId "A156N7AB89AXNZQ" (id=256)
ipAddr "10.209.66.64" (id=257)
isCoordinatingDiscoveryServer Boolean (id=258)
isInstanceInfoDirty false
isSecurePortEnabled false
isUnsecurePortEnabled true
lastDirtyTimestamp Long (id=260)
lastUpdatedTimestamp Long (id=263)
leaseInfo LeaseInfo (id=264)
metadata ConcurrentHashMap<K,V> (id=266)
overriddenstatus InstanceInfo$InstanceStatus (id=267)
port 8761
secureHealthCheckUrl null
securePort 443
secureVipAddress null
secureVipAddressUnresolved null
sid "na" (id=270)
status InstanceInfo$InstanceStatus (id=271)
statusPageExplicitUrl null
statusPageRelativeUrl "/Status" (id=272)
statusPageUrl "http://A156N7AB89AXNZQ:8761/Status" (id=273)
version "unknown" (id=274)
vipAddress "say-hello" (id=275)
vipAddressUnresolved "say-hello" (id=275)
I am running out of idea. Can anyone please give a hand on this problem?
Ribbon (https://github.com/Netflix/ribbon) and Eureka (https://github.com/Netflix/eureka) can work without Spring (and that is the way they were developed in the first place) but you will need to put a bit more effort into configuring everything to your needs.
Support for Ribbon and Eureka in Spring is part of the Spring Cloud project (and mvn group id), not Spring Boot. I don't think boot is mandatory. Ribbon and Eureka themselves are provided by Netflix.
For ribbon, you need to define your own #LoadBalanced RestTemplate #Bean anyway. #EnableDiscoveryClient should work as long as the dependencies have spring cloud eureka and your class is a #Configuration class.
Short answer is - why not try a quick test? :).