Skip to content

Commit

Permalink
feat($Consul): support Consul; abandon Netflix Eureka
Browse files Browse the repository at this point in the history
BREAKING CHANGE: support Consul; abandon Netflix Eureka
  • Loading branch information
johnnymillergh committed Feb 4, 2021
1 parent 20ddcad commit abc1cf8
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8760/eureka/

spring:
cloud:
consul:
host: localhost
port: 8500
zipkin:
base-url: http://localhost:9411
devtools:
Expand Down
46 changes: 19 additions & 27 deletions api-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ spring:
sampler:
probability: 1.0
cloud:
consul:
config:
enabled: true
prefix: config
# `default-context` should be equal to Spring application name
default-context: ${spring.application.name}
profile-separator: "-"
format: YAML
data-key: "data"
watch:
enabled: true
delay: 1000
discovery:
register: true
instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name}
service-name: ${spring.application.name}
port: ${server.port}
prefer-ip-address: true
ip-address: ${spring.cloud.client.ip-address}
gateway:
discovery:
locator:
Expand All @@ -29,33 +48,6 @@ spring:
allowedOrigins: "*"
allowedMethods: "*"

eureka:
instance:
leaseRenewalIntervalInSeconds: 10
health-check-url-path: /actuator/health
status-page-url-path: /
metadata-map:
# needed to trigger info and endpoint update after restart
startup: ${random.int}
instance-id: ${spring.cloud.client.ip-address}:${server.port}@${spring.cloud.client.hostname}@${spring.application.name}-${random.int}
prefer-ip-address: true
client:
registryFetchIntervalSeconds: 5

feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 10000
loggerLevel: full
compression:
request:
enabled: true
response:
enabled: true
useGzipDecoder: true

management:
endpoints:
web:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8760/eureka/

spring:
cloud:
consul:
host: localhost
port: 8500
zipkin:
base-url: http://localhost:9411
devtools:
Expand Down
34 changes: 20 additions & 14 deletions auth-center/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ spring:
# `file-size-threshold` specifies the size threshold after which files will be written to disk.
# The default is 0. We set it as 0 too.
file-size-threshold: 0
cloud:
consul:
config:
enabled: true
prefix: config
# `default-context` should be equal to Spring application name
default-context: ${spring.application.name}
profile-separator: "-"
format: YAML
data-key: "data"
watch:
enabled: true
delay: 1000
discovery:
register: true
instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name}
service-name: ${spring.application.name}
port: ${server.port}
prefer-ip-address: true
ip-address: ${spring.cloud.client.ip-address}
datasource:
name: muscle_and_fitness
type: com.alibaba.druid.pool.DruidDataSource
Expand Down Expand Up @@ -73,7 +93,6 @@ spring:
reset-enable: false
login-username: root
login-password: 123456

redis:
database: 0
timeout: 10000ms
Expand All @@ -84,19 +103,6 @@ spring:
max-wait: -1ms
min-idle: 0

eureka:
instance:
leaseRenewalIntervalInSeconds: 10
health-check-url-path: /actuator/health
status-page-url-path: /
metadata-map:
# needed to trigger info and endpoint update after restart
startup: ${random.int}
instance-id: ${spring.cloud.client.ip-address}:${server.port}@${spring.cloud.client.hostname}@${spring.application.name}-${random.int}
prefer-ip-address: true
client:
registryFetchIntervalSeconds: 5

feign:
client:
config:
Expand Down
10 changes: 10 additions & 0 deletions docker/docker-compose.development-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ services:
networks:
muscle_and_fitness_network:

consul-service-registry:
container_name: maf.consul-service-registry.development
hostname: maf.consul-service-registry.development
image: consul:latest
ports:
- "8500:8500"
volumes:
- ~/docker-file-mapping/maf.consul-service-registry.development:/consul/data
command: "agent -server -ui -disable-host-node-id -bootstrap-expect=1 -client=0.0.0.0"

################################################################################
# Microservice of Muscle and Fitness #
################################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8760/eureka/

spring:
cloud:
consul:
host: localhost
port: 8500
zipkin:
base-url: http://localhost:9411
devtools:
Expand Down
33 changes: 20 additions & 13 deletions exercise-mis/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ spring:
# `file-size-threshold` specifies the size threshold after which files will be written to disk.
# The default is 0. We set it as 0 too.
file-size-threshold: 0
cloud:
consul:
config:
enabled: true
prefix: config
# `default-context` should be equal to Spring application name
default-context: ${spring.application.name}
profile-separator: "-"
format: YAML
data-key: "data"
watch:
enabled: true
delay: 1000
discovery:
register: true
instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name}
service-name: ${spring.application.name}
port: ${server.port}
prefer-ip-address: true
ip-address: ${spring.cloud.client.ip-address}
datasource:
name: muscle_and_fitness
type: com.alibaba.druid.pool.DruidDataSource
Expand Down Expand Up @@ -83,19 +103,6 @@ spring:
max-wait: -1ms
min-idle: 0

eureka:
instance:
leaseRenewalIntervalInSeconds: 10
health-check-url-path: /actuator/health
status-page-url-path: /
metadata-map:
# needed to trigger info and endpoint update after restart
startup: ${random.int}
instance-id: ${spring.cloud.client.ip-address}:${server.port}@${spring.cloud.client.hostname}@${spring.application.name}-${random.int}
prefer-ip-address: true
client:
registryFetchIntervalSeconds: 5

feign:
client:
config:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8760/eureka/

spring:
cloud:
consul:
host: localhost
port: 8500
zipkin:
base-url: http://localhost:9411
devtools:
Expand Down
20 changes: 20 additions & 0 deletions muscle-mis/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ spring:
sleuth:
sampler:
probability: 1.0
cloud:
consul:
config:
enabled: true
prefix: config
# `default-context` should be equal to Spring application name
default-context: ${spring.application.name}
profile-separator: "-"
format: YAML
data-key: "data"
watch:
enabled: true
delay: 1000
discovery:
register: true
instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name}
service-name: ${spring.application.name}
port: ${server.port}
prefer-ip-address: true
ip-address: ${spring.cloud.client.ip-address}
datasource:
name: muscle_and_fitness
type: com.alibaba.druid.pool.DruidDataSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
spring:
devtools:
add-properties: true
cloud:
consul:
host: localhost
port: 8500
zipkin:
base-url: http://localhost:9411
datasource:
Expand All @@ -12,11 +16,6 @@ spring:
port: 6379
password: 123456

eureka:
client:
serviceUrl:
defaultZone: http://localhost:8760/eureka/

maf:
configuration:
swagger-disabled: false
Expand Down
33 changes: 20 additions & 13 deletions spring-boot-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: Asia/Hong_Kong
cloud:
consul:
config:
enabled: true
prefix: config
# `default-context` should be equal to Spring application name
default-context: ${spring.application.name}
profile-separator: "-"
format: YAML
data-key: "data"
watch:
enabled: true
delay: 1000
discovery:
register: true
instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name}
service-name: ${spring.application.name}
port: ${server.port}
prefer-ip-address: true
ip-address: ${spring.cloud.client.ip-address}
datasource:
name: muscle_and_fitness
type: com.alibaba.druid.pool.DruidDataSource
Expand Down Expand Up @@ -68,19 +88,6 @@ spring:
max-wait: -1ms
min-idle: 0

eureka:
instance:
leaseRenewalIntervalInSeconds: 10
health-check-url-path: /actuator/health
status-page-url-path: /
metadata-map:
# needed to trigger info and endpoint update after restart
startup: ${random.int}
instance-id: ${spring.cloud.client.ip-address}:${server.port}@${spring.cloud.client.hostname}@${spring.application.name}-${random.int}
prefer-ip-address: true
client:
registryFetchIntervalSeconds: 5

management:
endpoints:
web:
Expand Down

0 comments on commit abc1cf8

Please sign in to comment.