Make sure you have both developer accounts mentioned in prerequisites. Also make sure you have cloudant and weatherinsights services created as listed in step 1.
In this scenario, we take the Flightassist which is factored to use the weather microservice. Since Cloud Foundry apps (warden containers) are not allowed to talk privately, they need to communicate via public route.
We first push the python microservice.
bx app push {your_unique_proxy_name} -f flightassist-weather/manifest.yml
Note: If you want to use
cf
commands, please install cloudfoundry CLI and replace all thebx app push
command withcf push
make sure you pick a unique name for the app.
This will bring up the first app we need.
The output should look like:
requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: {proxy_name}.mybluemix.net
last uploaded: Thu Jun 8 21:36:15 UTC 2017
stack: unknown
buildpack: python_buildpack
And we need the urls for next step.
Now we will push the second app, but without starting it.
bx app push {your_unique_app_name} -f main_application/manifest.yml --no-start
make sure you pick a unique name for the app, too.
Now we inject the environment variables as in monolithic deployment:
FLIGHTSTATS_APP_ID
: application ID assigned by FlightStatsFLIGHTSTATS_APP_KEY
: application key assigned by FlightStatsTRIPIT_API_KEY
: API key assigned by TripItTRIPIT_API_SECRET
: API secret assigned by TripItBASE_URL
: You URL for accessing your application. In the format https://{name2}.mybluemix.net/
Plus, a couple more since we have two apps:
USE_WEATHER_SERVICE
: trueMICROSERVICE_URL
: {proxy_name}.mybluemix.net
Now we start the 2nd app:
bx app start {app_name}
You can now test the apps by going to http://{app_name}.mybluemix.net
To push an app, we simply use bx app push
or cf push
command. There is no container image or repository involved. Cloud Foundry has wide inventories of build packs to support different programming languages. If you run cf marketplace
, you can find the huge list of services provided by Bluemix that can easily be consumed by your application. When pushing multiple microservices that need to communicate to each other, however, the experience is not so smooth. Another common alternative to creating public routes and sharing information through environment variables as used in this example, is to bind a message queue service for communication.
File | Description |
---|---|
flightassist.js | Main application, start the express web server and calling the major AJAX functions |
All JavaScript files (main_application/*.js) | The implementation of the flightstats, tripIt, and weather information, shared by all deployment options |
app.py | Weather Microservice, query and sent weather information to the main application |
Procfile and requirements.txt | Description of the microservice to be deployed |
package.json | List the packages required by the application |
manifest.yml | Description of the application to be deployed |