Netflix Eureka and Spring Boot Admin in one application, not showing clients - netflix-eureka

i'm trying to add Spring Boot Admin to my Eureka Server, but it looks like there is something wrong somewhere.
I'm using
Spring Boot version 2.1.5.RELEASE (starter parent)
spring-cloud-starter-netflix-eureka-server
spring-boot-admin-starter-server
My Main Class is annotated with
#SpringBootApplication
#EnableAdminServer
#EnableEurekaServer
And this is the application.yml
spring:
application:
name: eureka-server
boot:
admin:
context-path: /admin
security:
basic:
enabled: false
management:
security:
enabled: false
eureka:
client:
register-with-eureka: false
fetch-registry: true
instance:
leaseRenewalIntervalInSeconds: 15
After i started the server, i try to launch a microservice
The application.yaml go the client is the following:
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
leaseExpirationDurationInSeconds: 5
client:
service-url:
default-zone: http://localhost:8761/eureka
healthcheck:
enabled: true
lease:
duration: 5
management:
endpoints:
web:
exposure:
include: '*'
security:
enabled: false
but i see it in eureka as down
and i cannot see anything in SBA

Related

Eureka service UP, SBA DOWN

I user SBA as discovery client (spring-boot-admin.version 2.1.5) to Eureka server. I see a registered application UP in Eureka server, but the same is DOWN on SBA.SBA app
These is my application.yml
spring:
application:
name: spring-boot-admin-sample-eureka
profiles:
active:
- secure
server:
port : 8091
tag::configuration-eureka[]
eureka: #<1>
instance:
leaseRenewalIntervalInSeconds: 10
statusPageUrlPath: /actuator/info
health-check-url-path: /actuator/health
metadata-map:
startup: ${random.int} #needed to trigger info and endpoint update after restart
management.context-path: /monitor-client/actuator
client:
registryFetchIntervalSeconds: 5
registerWithEureka: false
serviceUrl:
defaultZone: http://localhost:8761/ServicesRepository/eureka
management:
endpoints:
web:
exposure:
include: "*" #<2>
endpoint:
health:
show-details: ALWAYS
security:
enabled: false
end::configuration-eureka[]
spring:
profiles: insecure
spring:
profiles: secure
security:
user:
name: "user"
password: "password"
eureka:
instance:
metadata-map:
user.name: "user" #These two are needed so that the server
user.password: "password" #can access the protected client endpoints
spring:
boot:
admin:
client:
username: user
password: password
instance:
metadata:
user.name: user
user.password: password
Always show details in Health check section
management:
endpoint:
health:
show-details: "ALWAYS"
endpoints:
web:
exposure:
include: "*"

How to make spring cloud stubrunner boot register stubs in Eureka Discovery?

I'm trying to register my cloud contract stubs with a running Eureka discovery service for smoke-testing. The stubrunner itself is successfully registered in the service discovery, but the endpoints provided by the stubs are not reachable as expected.
The stubs should replace the real masterdata microservice (rest apis).
Stubrunner main class:
#SpringBootApplication
#EnableStubRunnerServer
#EnableEurekaClient
#AutoConfigureStubRunner
class EurekaStubRunnerApplication
fun main(args: Array<String>) {
runApplication<EurekaStubRunnerApplication>(*args)
}
Stubrunner bootstrap.yml
spring:
application:
name: masterdata
jhipster:
registry:
password: admin
Stubrunner application.yml
eureka:
client:
service-url:
defaultZone: http://admin:${jhipster.registry.password}#localhost:8761/eureka/
enabled: true
healthcheck:
enabled: false
fetch-registry: true
register-with-eureka: true
instance-info-replication-interval-seconds: 10
registry-fetch-interval-seconds: 10
instance:
appname: masterdata
instance-id: masterdata:${spring.application.instance-id:${random.value}}
lease-renewal-interval-in-seconds: 5
lease-expiration-duration-in-seconds: 10
status-page-url-path: management/info
health-check-url-path: management/health
ribbon:
eureka:
enabled: true
server:
port: 8888
stubrunner:
cloud:
eureka:
enabled: true
stubbed:
discovery:
enabled: true
Command to start stub runner:
java -jar eureka-stub-runner-0.0.1-SNAPSHOT.jar --stubrunner.ids=com.xetics.mes:masterdata-stubs:+:8081 --stubrunner.stubsMode=LOCAL
When I start the real masterdata service, I can call the api endpoint via the running gateway:
curl -X GET --header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOLFJPTEVfVVNFUiIsImV4cCI6MTU0NjYxMDc2OH0.EF3PHho-B-ayOmmeFrcA90U38cd3AZsU7pA7-9xN0SpuVBvev2sHvejv-FI_FlrwP7qWcCpibW-yWwFDBSUv9w' 'http://localhost:8080/masterdata/api/stations'
[]
The same call with stubs running in the stub runner:
curl -X GET --header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOLFJPTEVfVVNFUiIsImV4cCI6MTU0NjYxMDc2OH0.EF3PHho-B-ayOmmeFrcA90U38cd3AZsU7pA7-9xN0SpuVBvev2sHvejv-FI_FlrwP7qWcCpibW-yWwFDBSUv9w' 'http://localhost:8080/masterdata/api/stations'
{"timestamp":"2019-01-03T16:59:36.426+0000","status":404,"error":"Not Found","message":"No message available","path":"/api/stations"}
Although, I can call the stubs directly:
curl -X GET --header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOLFJPTEVfVVNFUiIsImV4cCI6MTU0NjYxMDc2OH0.EF3PHho-B-ayOmmeFrcA90U38cd3AZsU7pA7-9xN0SpuVBvev2sHvejv-FI_FlrwP7qWcCpibW-yWwFDBSUv9w' 'http://localhost:8081/api/stations'
[{"archiveTime":null,"description":"A fantastic base for building a time machine","id":1985,"maxCapacity":2,"name":"DeLorean DMC 12","icon":"delorean-icon"},{"archiveTime":null,"description":"A handy tool for manipulating the space time continuum","id":2015,"maxCapacity":1,"name":"Flux capacitor"}]
What am I doing wrong? As far as I understood that issue https://github.com/spring-cloud/spring-cloud-contract/pull/64 , it should be possible to register the stubs in the Eureka server, nor?
I've also read the following documentations without any success:
https://cloud.spring.io/spring-cloud-contract/1.0.x/#_additional_configuration
https://github.com/spring-cloud/spring-cloud-contract/tree/master/spring-cloud-contract-stub-runner
The problem were caused by the following misconfiguration of the application.
...
stubrunner:
cloud:
eureka:
enabled: true
stubbed:
discovery:
# must be false instead of
enabled: true
In addition, I needed to add a service mapping as my stubs artifact id is masterdata-stubs whereas the service id to call is masterdata.
The working application.yml looks like this now:
eureka:
client:
service-url:
defaultZone: http://admin:${jhipster.registry.password}#localhost:8761/eureka/
enabled: true
healthcheck:
enabled: false
fetch-registry: true
register-with-eureka: true
instance-info-replication-interval-seconds: 10
registry-fetch-interval-seconds: 10
instance:
appname: stubrunner
instance-id: stubrunner:${spring.application.instance-id:${random.value}}
lease-renewal-interval-in-seconds: 5
lease-expiration-duration-in-seconds: 10
status-page-url-path: management/info
health-check-url-path: management/health
ribbon:
eureka:
enabled: true
server:
port: 8888
stubrunner:
cloud:
eureka:
enabled: true
stubbed:
discovery:
enabled: false
idsToServiceIds:
masterdata-stubs: masterdata

Configure Eureka Server and client with custom port and address

I have a Eureka Server running on default localhost host and port 8761, so i tried to change this default configuration in this way:
server:
port: 6000
servlet:
context-path: /myeureka
eureka:
client:
register-with-eureka: false
fetch-registry: false
But in this way i can't access eureka dashboard, just using default configuration:
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
In my client same thing occurrs, i can't point to another eureka server different from default (localhost:8761), see my configuration:
server:
port: 7000
servlet:
context-path: /client-eureka
spring:
application:
name: client-eureka
eureka:
instance:
prefer-ip-address: true
client:
eureka-server-port: 6000
eureka-server-u-r-l-context: /myeureka
Lookin in client log i got the following:
2018-09-01 09:19:37.175 INFO 4931 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://localhost:8761/eureka/
No matter what port or host i configure in client, always try to reach the default.
Important:
I'm using eureka in this version: https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server/2.0.1.RELEASE
I used the same dependency version as yours and cannot find the config path server.servlet.contextpath
Instead, you can use either server.servlet-path or server.context-path
With each of the server configuration, you need to update your client application.yml file too. Remember that /eureka is the default REST endpoint used to register Eureka client with Eureka server
Case 1: Use server.servlet-path
Eureka Server:
server:
port: 7000
servlet-path: /myeureka
eureka:
client:
register-with-eureka: false
fetch-registry: false
Eureka Client:
spring:
application:
name: spring-cloud-eureka-client
server:
port: 0
eureka:
client:
service-url:
defaultZone: ${EUREKA_URI:http://localhost:7000/eureka}
instance:
preferIpAddress: true
Case 2: Use server.context-path
Eureka Server:
server:
port: 7000
context-path: /myeureka
eureka:
client:
register-with-eureka: false
fetch-registry: false
Eureka Client:
spring:
application:
name: spring-cloud-eureka-client
server:
port: 0
eureka:
client:
service-url:
defaultZone: ${EUREKA_URI:http://localhost:7000/myeureka/eureka}
instance:
preferIpAddress: true
Updated answer:
Because server.servlet-path and server.context-path were deprecated, eureka server will be configured as following:
server:
port: 7000
servlet:
context-path: /myeureka
eureka:
client:
register-with-eureka: false
fetch-registry: false
Eureka client application.yml will be kept as in Case 2.

Springcloud: Zuul + Eureka not working

I spent all day trying to make Zuul + Eureka work together, but I hasn't been lucky with that. Zuul alone, without Eureka, works fine. I've tried a lot of different configurations like this one, which says that all I have to do is turn Zull in an Eureka client (by using #EnableDiscoveryClient at root application class).
My setup is very simple: it consists of a service:8080 (service 1), Zuul:9000 and Eureka:8761.
All the approaches I've tried using Eureka gave me the same error when I tried to access service 1 using Zull (http://localhost:9000/service1 in this case):
com.netflix.zuul.exception.ZuulException: Forwarding error
(...)
com.netflix.client.ClientException: Load balancer does not have available server for client: service1
Service 1 is working fine (I can access it directly from the browser address bar http://localhost:8080) and Eureka shows both Zull and Service 1 correctly registered:
The apps are configured like:
Service 1 (bootstrap.yml):
spring:
application:
name: service1
Service 1 (application.yml):
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
Zuul:
ribbon:
eureka:
enabled: false
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
healthcheck:
enabled: true
server:
port: 9000
Eureka:
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
logging:
level:
com:
netflix:
eureka: OFF
discovery: OFF
Zuul Annotations at root application class:
#EnableZuulProxy
#EnableDiscoveryClient
Am I missing any important point?

Unable to run Spring Cloud Config-Server in Eureka First Bootstrap mode

*****Config Server- Application Service Setup*****
Below is the configuration from application.yml
server:
port: 8882
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
cloud:
config:
server:
git:uri: https://github.com/appleman/config
Below is the configuration from boostrap.yml
spring:
application:
name: configserver
Starting of this plain spring boot application registers config-server to Eureka.
**General Eureka Server is running on 8761 port
********Below is the Application Client configuration*****
Below is the Application Client configuration in my bootstrap.yml
spring:
application:
name: contractService,envDEV13
cloud:
config:
enabled: true
discovery:
enabled: true
serviceId: configserver
eureka:
instance:
nonSecurePort: ${server.port:8080}
client:
serviceUrl:
defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/
Injection of properties in Spring Controller like the below snippet is not working.
#Value("${creditService.eppDbUrl}")
String bar;
Please suggest us if we are doing anything wrong.