简体   繁体   中英

Deploying microservices to Cloud Foundry

I developed a simple prototype of a complete microservice architecture with Spring Cloud and OSS libraries that I can run fluently on my computer. I'm trying to deploy the whole thing to Cloud Foundry, and going throught the documentation I found a lot of articles discussing how to use PCF discovery service, but how about using our eureka server? I tried to use user provided service but my microservices can't bind to the URL even when restaging them. How can I achieve such thing?

The second question is (If I can make eureka works): should I declare my config server also as a user provided service?

Following the docs create-user-provided-service

You should first create the cups like this:

  1. cf cups SERVICE_INSTANCE -p PATH_TO_FILE

the file could be a json file with a content like this: {"key1":"value1","key2":"value2"}

  1. bind your app to the service through a manifest.yml file that resides in your app directory
services: 
 -SERVICENAME
  1. get the service value through an application.yml file property like this

    url: ${vcap.services.servicename.key1}

    for default values you can do

    url: ${vcap.services.servicename.key1:defaultURL}

After you have created the cups, the manifest.yml and the aplication.yml, you have to push your application or restart it.

Should I declare my config server also as a user provided service?

I believe you should, your config server will probably be accesed by multiple microservices therefore you should keep the config server url in the user provided service and connect your multiple apps to this service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM