In Cloud config, we store config which can be accessed by other micro services. In Eureka also we store config info. So what is the difference and when to use what?
After learning some more I understood that Eureka is not meant for storing config. It is meant for service registry and discovery. Cloud Config acts as a centralized config mechanism. Eureka on the other hand is meant so that services can discover each other without having to hard code the host and port anywhere.
To my knowledge of experiments on spring cloud config server and spring cloud Netflix's Eureka server,I found below things,
---
spring:
cloud:
config:
server:
git:
uri: https://github.com/username/repository-name
searchPaths: ConfigData
# "native" is used when the native profile is active, for local tests with a classpath repo:
native:
searchLocations: classpath:offline-repository/
server:
port: 8001
If you see yml file I have given uri as git-uri where my other spring-profiles are placed under ConfigData folder and I'm telling in which port server should run i.e., 8001.
Now when you run your cilent application with below yml file configured
---
spring:
profiles:
active: northamerica
application:
name: lab-3-client
cloud:
config:
uri: http://localhost:8001
server:
port: 8002
all your client properties will be overwritten by server properties.
---
spring:
profiles: default
server:
port: 8010
eureka:
instance:
hostname: eurekahost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
by using below yml file and @EnableDiscoveryClient cilent wil register to eureka server which you can't be done using sprin-cloud-config-server
---
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8010/eureka/
server:
port: ${PORT:${SERVER_PORT:0}} # Select any available port if neither port nor server port are specified.
By looking into all the configurations what I understand is
a) With the Config Server you have a central place to manage external properties for applications across all environments.
b) For registering multiple clients to multiple servers, spring-cloud-eureka is used
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