2017-03-23 55 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

相關問題