I try to run Eureka Server and Spring Boot Admin Server in one Application (SBA Docu says this is possible). Eureka is working as intended but the Admin App still shows zero Applications.
Spring Boot Version 2.0.3, Spring Boot Admin Version 2.0.1
Eureka and SBA Server
@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
@EnableAdminServer
class KotlintestApplication
fun main(args: Array<String>) {
SpringApplication.run(KotlintestApplication::class.java, *args)
}
Server bootstrap.yml
spring:
application:
name: server
Server application.yml
spring:
boot:
admin:
context-path: /admin
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8080/eureka
Client
@EnableDiscoveryClient
@SpringBootApplication
class KotlintestApplication
fun main(args: Array<String>) {
SpringApplication.run(KotlintestApplication::class.java, *args)
}
@Configuration
class SecurityPermitAllConfig : WebSecurityConfigurerAdapter() {
@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http.authorizeRequests().anyRequest().permitAll()
.and().csrf().disable()
}
}
Client bootstrap.yml
spring:
application:
name: client
server:
port: 0
Client application.yml
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
eureka:
instance:
hostname: localhost
health-check-url-path: /actuator/health
status-page-url-path: /actuator/info
client:
serviceUrl:
defaultZone: http://127.0.0.1:8080/eureka/
After downloading the project in main Spring Boot Application class file, we need to add @EnableEurekaServer annotation. The @EnableEurekaServer annotation is used to make your Spring Boot application acts as a Eureka Server. Make sure Spring cloud Eureka server dependency is added in your build configuration file.
Eureka Server is service discovery for your microservices, where all client applications can register by themselves and other microservices look up the Eureka Server to get independent microservices to get the job complete.
First, you need to add the following dependencies in our build configuration file to register the microservice with the Eureka server. Now, we need to add the @EnableEurekaClient annotation in the main Spring Boot application class file.
Spring Boot Admin Server is an application used to manage and monitor your Microservice application. To handle such situations, CodeCentric Team provides a Spring Boot Admin UI to manage and monitor all your Spring Boot application Actuator endpoints at one place.
Found the answer myself
Remove the fetchRegistry: false
from the server application.yaml.
The Server has to fetch the registry to see the clients ...
Btw: You should set an instanceId if you want to run multiple instances with a random port on the same host. Otherwise SBA can't differ between the instances.
eureka:
instance:
instanceId : client-${random.uuid}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With