[英]Can Netflix Eureka server be used as a proxy between microservices environments?
Thanks in advance everyone looking at this!提前感谢所有关注这个的人!
Here is what I'm trying to do:这是我正在尝试做的事情:
I am developing microservices using Spring-Boot/Java with Zuul and Eureka as gateway and registry respectively.我正在使用 Spring-Boot/Java 开发微服务,Zuul 和 Eureka 分别作为网关和注册表。 The problem I'm having is that I want to develop my new microservice locally but still be able to make calls to my other existing microservices running on a remote cluster.
我遇到的问题是我想在本地开发我的新微服务,但仍然能够调用我在远程集群上运行的其他现有微服务。 My thinking is that I can run Eureka locally and using its peering capability to forward failed local requests to the Eureka server that lives in the remote cluster.
我的想法是我可以在本地运行 Eureka,并使用其对等功能将失败的本地请求转发到位于远程集群中的 Eureka 服务器。
My question:我的问题:
Is it possible to configure Eureka to register local services on my workstation but also forward/failover to a remote Eureka peer so that I am hitting the correct remote gateway for all my other remote microservices?是否可以将 Eureka 配置为在我的工作站上注册本地服务,但也可以转发/故障转移到远程 Eureka 对等方,以便我为所有其他远程微服务点击正确的远程网关?
This should be achievable by using Zones:这应该可以通过使用区域来实现:
https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/2.2.2.RELEASE/reference/html/#zones https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/2.2.2.RELEASE/reference/html/#zones
In order for that to work, you'd need to have the Eureka servers see eachother as peers.为了使其工作,您需要让 Eureka 服务器将彼此视为对等点。 The official docs for that are here:
官方文档在这里:
https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/2.2.2.RELEASE/reference/html/#spring-cloud-eureka-server-peer-awareness https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/2.2.2.RELEASE/reference/html/#spring-cloud-eureka-server-peer-awareness
You can configure your services to prefer a certain zone.您可以将服务配置为首选某个区域。
// Config for your production services
eureka.instance.metadataMap.zone = production
eureka.client.preferSameZoneEureka = true
// Config for your local services
eureka.instance.metadataMap.zone = local
eureka.client.preferSameZoneEureka = true
So any service you are running locally will be preferred but it will fall-back to the other zone if the service you call upon isn't running locally.因此,您在本地运行的任何服务都将是首选,但如果您调用的服务未在本地运行,它将回退到另一个区域。
Note : It is possible this way for a "production" instance to call your local instance if there are no instances of a given service running in the production cluster but you happen to be running them locally.注意:如果生产集群中没有运行给定服务的实例但您碰巧在本地运行它们,则“生产”实例可以通过这种方式调用您的本地实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.