Flightassist is a Node.js example application for demonstrating and comparing various application deployment technologies in the IBM Bluemix public cloud.
The intent for this project, when complete, is that it will be deployable as a Cloud Foundry application, a containerized application using at least one factored-out microservice, and as a set of functions deployable to OpenWhisk, the IBM Bluemix function-as-a-service offering.
Specifically, a set of trade-offs and comparisons can be made between these deployment models, and this application is a proving ground for those discussions. This will be the basis for the talk given by Lin Sun and Phil Estes at IBM Interconnect 2017 titled Containerize, PaaS, or Go Serverless? A Case Study in Application Deployment Models.
The scenarios are accomplished by using:
- Cloud Foundry
- Kubernetes Clusters
- OpenWhisk
- Cloudant NoSQL Database
- Insights for Weather
- TripIt Developer API
- FlightStats Developer API
Register and obtain the FlightStats Developer API and TripIt Developer API to query flight status.
When signing up for a FlightStats developer key, note that there is a review process that may take 24 hours or more to get your application credentials activated for a 30-day trial with the API.
Click the button to deploy your app and fill in all the variables from Delivery Pipeline and click create.
You should see a link under the Cloud Foundry stage and that's where your application is hosting.
Click View logs and history and access your application via the URL link at the end of your logs.
Since we need to create services using the command line, we need to install Bluemix CLI before proceeding to the following steps.
We will use Bluemix's The Cloudant NoSQL database service and Insights for Weather service for our database and weather data. Therefore, run the following commands to create cloudant and Insights for Weather service.
For this example, we recommend you name your services to mycloudant and myweatherinsights.
bx service create cloudantNoSQLDB Lite mycloudant bx service create weatherinsights Free-v2 myweatherinsightsBefore moving on, the demo application is missing code to create the databases used to cache API responses in your newly created Cloudant instance. You can run the following commands with your cloudant URL to create the databases.
bx service keys mycloudant #This will output your {service key} bx service key-show mycloudant {service key} #This will output your cloudant credential, "url" is Your cloudant URL curl -k -X PUT {your-cloudantURL}/trips curl -k -X PUT {your-cloudantURL}/weather curl -k -X PUT {your-cloudantURL}/connections- Scenario One: Deploy Flightassist on Cloud Platform using Cloud Foundry
- Scenario Two: Deploy Flightassist as containers using Docker Compose and Kubernetes Clusters
- Scenario Three: Deploy Flightassist with Serverless using OpenWhisk
After you deployed Flightassist using any platform, you can go to How to Use Flightassist and start testing your application.
In this scenario, we will deploy Flightassist as a monolithic application and host it on Cloud Foundry.
First, install Cloud Foundry CLI.
Then, type the following commands to push your application with your own unique application name.
cf push {your_unique_app_name}Now, go to https://console.ng.bluemix.net/dashboard/apps and select your application. Click the Runtime settings for your application and add these four environment variables to set up external credentials to the TripIt and FlightStats services:
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. e.g. {app_name}.mybluemix.net
Your application should restart automatically, but can be done manually as well in the UI. With the service bindings and added environment variables, the application should be operational at the hostname route you selected for your CF application.
Congratulation, now you can learn about How to Use Flightassist and start testing your application.
In this scenario, we want to break down Flightassist to multiple containers. Therefore, we will run Flightassist as our main application with weather-service as our microservice to query the weather data. Then, we will host those containers using Docker Compose or Kubernetes.
First, install Docker CLI.
Next, edit the docker-compose.yaml file and add your credentials for FLIGHTSTATS_APP_ID, FLIGHTSTATS_APP_KEY, TRIPIT_API_KEY,TRIPIT_API_SECRET,CLOUDANT_URL, and WEATHER_URL. You can run the following command to view your service credentials.
bx service keys {service_name} #This will output all your service keys bx service key-show {service_name} {service key} #This will output your service credential, "url" is Your service URLThen, run the following commands to build your docker images and run Docker Compose.
docker build -f Dockerfile.local -t flightassist . docker build -f flightassist-weather/Dockerfile.alpine -t weather-service flightassist-weather docker-compose upNow, your FlightAssist application should be running on http://localhost:3000/
First, follow the Kubernetes Cluster Tutorial to create your own cluster on Bluemix.
Then, install the container registry plugin for Bluemix CLI.
bx plugin install container-registry -r BluemixNext, build your own docker images and push them to your own bluemix container registry.
Replace
<namespace>with your own namespace, you can view your namespace by runningbx cr namespacesIf you have unauthorized error, run
bx cr loginto authorized your container-registry.
docker build -f Dockerfile.local -t registry.ng.bluemix.net/<namespace>/flightassist . docker build -f flightassist-weather/Dockerfile.alpine -t registry.ng.bluemix.net/<namespace>/weather-service flightassist-weather docker push registry.ng.bluemix.net/<namespace>/flightassist docker push registry.ng.bluemix.net/<namespace>/weather-serviceThen, you need to run the following commands to bind your Cloudant and Weather Insights services to your clusters.
bx cs cluster-service-bind {your-cluster-name} default mycloudant bx cs cluster-service-bind {your-cluster-name} default myweatherinsightsNext, modify the secret.yaml file with flightstats-app-id, flightstats-app-key, tripit-api-key, and tripit-api-secret.
Then, edit the flightassist.yaml and replace the <namespace> with your own namespace. You can obtain your namespace by running bx cr namespace. Also replace <your-app-end-point-url> with your node ip and nodeport (e.g. 169.47.237.139:30080). You can obtain your IP by running kubectl get nodes and your nodeport is 30080.
Lastly, run the following commands to deploy the secret and deployment.
kubectl create -f secret.yaml kubectl create -f flightassist.yamlCongratulation, now your Flightassist application should be running on http://<your_node_ip>:30080. You can go to How to Use Flightassist and start testing your application.
In this scenario, we will deploy Flightassist with serverless to show how you could replace your microservices with OpenWhisk actions.
Important: You must complete scenario two for Kubernetes Clusters in order to proceed the following steps.
First, you want to delete all the services and deployments from the previous scenario.
kubectl delete -f flightassist.yamlThen, install OpenWhisk CLI and Mark down its credentials.
Next, edit flightassist_serverless.yaml and replace the <namespace> with your own namespace, <your-app-end-point-url> with your node ip and nodeport, and <your-openwhisk-auth> with your OpenWhisk authendication. You can run wsk property get --auth | awk '{print $3}' to view your OpenWhisk authentication.
Now, let's deploy the new flightassist app with serverless.
kubectl create -f flightassist_serverless.yamlCongratulation, now your Flightassist application should be running on http://<your_node_ip>:30080. Also, you can learn about How to Use Flightassist and start testing your application.
First, you want to add a trip on TripIt. Then, add a new flight plan for your trip. In your plan, please fill in your confirmation number or airline with flight number.
Once you added a new plan and you have your Flightassist running, open your Flightassist and click Authenticate with TripIt to login to Flightassist.
Now you can see the most recent flight status and weather for all your flights within 24 hours.
This project is based on this flightassist example.
Phil Estes and Lin Sun are the main contributers for the flightassist example.


