Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eureka Server and Spring Boot Admin in one Application

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/
like image 445
Domo Avatar asked Jun 25 '18 13:06

Domo


People also ask

How do I enable Eureka server in Spring Boot?

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.

What is the purpose of Eureka server in Spring Boot?

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.

How do I register multiple Microservices in Eureka server?

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.

What is Admin server in Spring Boot?

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.


1 Answers

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}
like image 146
Domo Avatar answered Oct 07 '22 13:10

Domo