2017-03-23 63 views
2

我面临两个与在启用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

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

对于第一个有关基于路径的路由问题,它与开箱即用的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到正确的尤里卡的应用程序,并注册那些/ V1和/ V2不同名称的应用程序。

+0

谢谢! 是的,它出现在特定的环境中,我们仍然在版本1.1.1-版本6. 我想知道升级是否能解决第一个问题? – odedia

+0

我已更新答案以解决第一个问题 – fivetenwill

+0

非常感谢。除路由路径外,我将使用其他方法。 – odedia

相关问题