我面临两个与在启用Spring Cloud Services的情况下将微服务部署到云代工厂有关的问题。 首先,看起来如果我用CF路径路径部署应用程序,如果只是无法注册。我部署一个这样的程序:Cloud Foundry Service Registry(Eureka)失败Blue-Green部署和路由路径
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
应用程序获取由尤里卡注册,但它不能被发现。如果我打开从尤里卡中心的链接,它被翻译成这样的:
http://example.com/v1:80/info
http://example.com/v1:80/date
这个网址就是无法访问。其他应用程序尝试调用date-services microservice,并以“404未找到”失败。如果我从部署中删除路由路径 - 一切都很好。
另一个问题是蓝绿色部署。
如果我部署相同的罐子一款新应用程序的名称,如日期,服务绿色,我再次在尤里卡失败:
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
最终这些错误是否消失,但是,经过全蓝绿色的尤里卡的注册路线仍然指向GREEN,而不是原始路线。这是当然无法获得的。
这里是我运行命令:
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}
是尤里卡登记的最终网址是:
http://pcfdev01-date-services-sa-v1-green.cf.example.com/info
在URL中的“绿色”,根本谈不上工作。如果我从URL中删除“绿色”,它就会起作用。
我试过Camden.SR6和Brixton SR7。 Spring云服务是1.4.1.RELEASE。我相信CF环境中的运行时间是1.7。
谢谢。
谢谢! 是的,它出现在特定的环境中,我们仍然在版本1.1.1-版本6. 我想知道升级是否能解决第一个问题? – odedia
我已更新答案以解决第一个问题 – fivetenwill
非常感谢。除路由路径外,我将使用其他方法。 – odedia