Cloud Foundry Service Registry(Eureka)未能实现Blue-Green部署&路线路径

时间:2017-03-23 13:58:23

标签: cloudfoundry spring-cloud spring-cloud-netflix

我面临两个与在启用Spring Cloud Services的云代工厂部署微服务相关的问题。 首先,看来如果我部署一个带有CF路径路径的应用程序,如果只是无法注册。我部署了这样的应用程序:

cf push -p target/date-services-1.0.jar --hostname env5-date-services --route-path /v1 -f manifest.yml date-services-v1 清单看起来像这样:

applications:
- name: date-services-v1
  memory: 1024M
  instances: 1
  timeout: 180
  env:
    JBP_CONFIG_OPEN_JDK_MEMORY_CALCULATOR: "[memory_sizes: {metaspace: 180m}, memory_heuristics: {metaspace:  25}]"
  services:
  - rabbitmq
  - config-server
  - discovery
  - circuit-breaker
  - mysql

该应用程序由Eureka注册,但无法找到。如果我从Eureka仪表板打开链接,它将被翻译为:

http://example.com/v1:80/info
http://example.com/v1:80/date

此网址无法访问。其他应用程序尝试调用日期服务微服务并因“未找到404”而失败。如果我删除路径路径 - 从部署 - 一切都很好。

另一个问题是蓝绿色部署。

如果我将同一个jar部署到一个新的应用程序名称,例如date-services-GREEN,那么我在Eureka中失败了:

Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT 2017-03-23 07:21:16.225 ERROR [date-services-sa-v1,,,] 20 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_date-services-SA-V1/pcfdev01-date-services-sa-v1-GREEN.apps.cf.example.com:84e48618-3b11-46e4-7b3e-f638788786ea - was unable to send heartbeat!
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:815)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT 2017-03-23 07:21:16.225 WARN [date-services-sa-v1,,,] 20 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_date-services-SA-V1/pcfdev01-date-services-sa-v1-GREEN.apps.cf.example.com:84e48618-3b11-46e4-7b3e-f638788786ea - registration failed Cannot execute request on any known server
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:837)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1396)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.lang.Thread.run(Thread.java:745)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:815)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:837)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1396)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT at java.lang.Thread.run(Thread.java:745)
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT 2017-03-23 07:21:16.306 INFO [date-services-sa-v1,,,] 20 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_date-services-SA-V1/pcfdev01-date-services-sa-v1-GREEN.apps.cf.example.com:84e48618-3b11-46e4-7b3e-f638788786ea: registering service...
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
Thu Mar 23 2017 09:21:16 GMT+0200 (IST) [APP] OUT 2017-03-23 07:21:16.331 WARN [date-services-sa-v1,,,] 20 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failure with status code 403; retrying on another server if available

最终这些错误消失了,但是在完全蓝绿色之后,尤里卡的注册路线仍然指向绿色而不是原始路线。哪个是无法进入的。

以下是我正在运行的命令:

cf push -p artifact.jar --hostname ${ENV_NAME}-${HOST_NAME}-${VERSION_NUMBER}-GREEN  -f manifest.yml ${TARGET_JOB_NAME}-GREEN

cf map-route ${TARGET_JOB_NAME}-GREEN ${DOMAIN} --hostname ${ENV_NAME}-${HOST_NAME}-${VERSION_NUMBER}

cf delete-route ${DOMAIN} -f --hostname ${ENV_NAME}-${HOST_NAME}-${VERSION_NUMBER}-GREEN

cf rename ${TARGET_JOB_NAME}-GREEN ${TARGET_JOB_NAME}

在Eureka注册的最终网址是:

http://pcfdev01-date-services-sa-v1-green.cf.example.com/info

使用网址中的“绿色”,它根本不起作用。如果我从URL中删除“绿色”,则可以正常工作。

我尝试过Camden.SR6和Brixton SR7。 Spring Cloud Services是1.4.1.RELEASE。我相信CF环境中的运行时间是1.7。

感谢。

1 个答案:

答案 0 :(得分:1)

您的环境中安装了哪个版本的Spring Cloud Services磁贴?要在同一空间中进行蓝绿色部署的应用程序,您必须使用1.2或更高版本,请参阅http://docs.pivotal.io/spring-cloud-services/1-2/security-overview.html#service-registry-virtual-hostname-ownership。该部分讨论了PCF安装中的应用程序,但在PCF中,您可以将多个应用程序注册为相同的Eureka appname /虚拟主机名,但前提是它们都在同一空间中。

关于基于路径的路由的第一个问题,它与开箱即用的Eureka不兼容。该应用程序将注册主机名+路径(取自vcap.application.uris),此值将进入注册表中的主机名字段。功能区不期望这样:https://github.com/Netflix/ribbon/blob/v2.2.2/ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/LoadBalancerContext.java#L572您可以尝试在此处覆盖该行为:https://github.com/spring-cloud/spring-cloud-netflix/blob/v1.3.0.RC1/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerContext.java

另一种方法可能是使用Zuul将/ v1和/ v2映射到正确的Eureka应用程序,并使用不同的名称注册/ v1和/ v2应用程序。