Cloud foundry 云铸造服务注册中心(Eureka)蓝绿部署失败&;路径

Cloud foundry 云铸造服务注册中心(Eureka)蓝绿部署失败&;路径,cloud-foundry,spring-cloud,spring-cloud-netflix,Cloud Foundry,Spring Cloud,Spring Cloud Netflix,在启用Spring云服务的情况下,我面临两个与将微服务部署到cloud foundry相关的问题。 首先,如果我使用CF route path部署一个应用程序,if将无法注册。我部署的应用程序如下: applications: - name: date-services-v1 memory: 1024M instances: 1 timeout: 180 env: JBP_CONFIG_OPEN_JDK_MEMORY_CALCULATOR: "[memory_sizes:

在启用Spring云服务的情况下,我面临两个与将微服务部署到cloud foundry相关的问题。 首先,如果我使用CF route path部署一个应用程序,if将无法注册。我部署的应用程序如下:

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
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
此URL无法访问。其他应用程序尝试调用日期服务微服务,但失败为“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
最终这些错误消失了,但是在完全蓝绿色之后,Eureka中注册的路线仍然指向绿色,而不是原始路线。这当然是不可能的

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

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中注册的最终URL为:

http://pcfdev01-date-services-sa-v1-green.cf.example.com/info
URL中的“绿色”根本不起作用。如果我从URL中删除“绿色”,它就会工作

我试过Camden.SR6和Brixton SR7。SpringCloudServices是1.4.1.0版本。我相信CF环境中的运行时是1.7


谢谢。

您的环境中安装了哪个版本的Spring云服务磁贴?要在同一空间中以蓝绿色部署应用程序,您必须使用1.2或更高版本,请参阅。该部分讨论了PCF安装中的应用程序,但在PCF中,您可以将多个应用程序注册为同一个Eureka appname/虚拟主机名,前提是它们都在同一空间中

关于基于路径的路由的第一个问题,它与Eureka开箱即用不兼容。应用程序将使用hostname+路径(取自vcap.application.uris)注册,该值将进入注册表中的hostname字段。Ribbon不希望出现这种情况:您可以尝试在此处覆盖该行为:


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

谢谢!是的,在特定的环境中,我们仍然使用版本1.1.1-build 6。我想知道升级是否也能解决第一个问题?非常感谢。我将使用不同于路由路径的方法。