Eureka Server and Spring Boot Admin in one Application
Asked Answered
S

1

9

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/
Sweptwing answered 25/6, 2018 at 13:15 Comment(1)
@EnableDiscoveryClient in SBA server is no longer requiredBremer
S
7

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}
Sweptwing answered 26/6, 2018 at 7:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.