我是春季靴子和春天云的新手。 我想问一下,我是否可以为多个地点(不同的国家/地区)提供一个尤里卡服务。
例如 一个eureka服务和一个应用程序服务运行两次 - 位置斯洛伐克和另一个位置CZECH。 然后我希望为该位置和另一个常见服务提供边缘服务。 有可能吗?
配置eureka-service
spring:
application:
name: eureka-service
server:
port: 8761
eureka:
instance:
preferIpAddress: true
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8761/eureka/
config service-common
server:
port: 9082
eureka:
instance:
preferIpAddress: true
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
配置服务-a
spring:
application:
name: service-a
eureka:
instance:
preferIpAddress: true
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
---
spring:
profiles: sk
server:
port: 9080
eureka:
instance:
metadataMap:
zone: skZone
---
spring:
profiles: cz
server:
port: 9081
eureka:
instance:
metadataMap:
zone: czZone
配置service-a-apigateway
spring:
application:
name: service-a-apigateway
zuul:
routes:
book-apigateway:
serviceId: service-a
path: /api/**
book-common-api:
serviceId: service-common
path: /common/**
eureka:
instance:
preferIpAddress: true
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
---
spring:
profiles: sk
server:
port: 9050
eureka:
instance:
metadataMap:
zone: skZone
---
spring:
profiles: cz
server:
port: 9051
eureka:
instance:
metadataMap:
zone: czZone
Service-a-apigateway(profile:sk)只能调用service-a(profile:sk)和service-common。配置文件(cz)具有相同的行为。这很好。 但是当service-a(profile:sk)关闭时,service-a-apigateway(profile:sk)可以调用service-a(profile:cz)。这种行为是不可取的。
答案 0 :(得分:0)
我是这么认为的,通过在zuul边缘和服务A上设置属性eureka.instance.metadataMap.zone
。
“默认情况下,它将用于在与客户端相同的区域中查找服务器...”
http://cloud.spring.io/spring-cloud-static/spring-cloud.html#_using_ribbon_with_eureka
答案 1 :(得分:0)