How to connect Config Client to Config server using Eureka server?

2.1k Views Asked by At

I have Scenario that whenever we use config server with config client we need to put in bootstrap.yaml. suppose my config server on port 9001 so i need to hardcore this value in properties file that is http://localhost:9001:/

My question is, "it is possible to connect config client to config server using eureka server so that we can remove hardcore properties"

1

There are 1 best solutions below

0
On

These are properties I used which solved my problem

Eureka properties

spring.application.name=discovery-server
eureka.client.registerWithEureka = true
eureka.client.fetchRegistry = false
server.port = 9050
eureka.client.serviceUrl.defaultZone=http://localhost:9050/eureka/

Config-server properties

spring:
  application:
    name: configserver
  cloud:
    config:
      server:
        git:
          uri: git-url
          username: git-username
          password: git-password
      fail-fast: true
    
server:
  port: 8080
    
eureka:
   client:
      serviceUrl:
         defaultZone: http://localhost:9050/eureka

Config-client properties

spring:
  application:
    name: x
  cloud:
    config:
      profile: dev
      fail-fast: true
      discovery:
        enabled: true
        service-id: CONFIGSERVER
      retry:
        initial-interval: 2000
        multiplier: 1.5
        max-interval: 60000
        max-attempts: 100
        
server:
  port: 8081

eureka:
   client:
      serviceUrl:
         defaultZone: http://localhost:9050/eureka
      fetch-registry: true
   instance:
    lease-renewal-interval-in-seconds: 10