Skip to content

PaaS platforms like Cloud Foundry, container orchestrators like Kubernetes, Serverless platforms like OpenWhisk and Service-mesh like Istio are all great technologies to deploy and manage your microservices on. In this code we look at deployment experience the different platforms provide, and what do we gain and loose by choosing one vs another.

License

Notifications You must be signed in to change notification settings

IBM/Microservices-deployment-with-PaaS-Containers-and-Serverless-Platforms

Repository files navigation

Build Status

Navigate application deployment options with Cloud Foundry, Kubernetes, OpenWhisk and Istio

PaaS platforms like Cloud Foundry, container orchestrators like Kubernetes, Serverless platforms like OpenWhisk and Service-mesh like Istio are all great technologies to deploy and manage your microservices on. Common wisdom says there is no such thing as too many choices, but abundance of choices can lead to analysis paralysis. In this code, we look at deployment experience the different platforms provide, and what do we gain and lose by choosing one vs another.

We start with a sample Node.js monolithic application, Flightassist, factor it into two microservices, and then use it for demonstrating and comparing various deployment technologies. A set of trade-offs and comparisions can be made between these deployment models, and this application provides a basis for those discussions.

architecure-diagram

Included Components

Prerequisites

Register and obtain the keys for 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.

Deploy using DevOps Toolchain

Click the button to deploy your app and fill in all the variables from Delivery Pipeline. For Further instructions, please follow the Toolchain instructions.

Create Toolchain

Toolchain Scenario One: Monolithic Application

You should see a link under the Cloud Foundry Deploy stage and that's where your application is hosting.

Toolchain Scenario Two: Microservices on Kubernetes Clusters, with or without Serverless capabilities

If you want to deploy with microservices, please leave the OpenWhisk Auth variable blank on Delivery Pipeline. Otherwise, fill in the OpenWhisk Auth variable to enable serverless for your Flightassist.

Then, click View logs and history under Kubernetes Deploy stage in your pipeline to access your application via the URL link at the end of your logs.

Steps

Part A: Deploy, test and factor monolithic application into microservices:

  1. Provision application services - Cloudant Database and Insights for Weather Service
  2. Deploy monolithic application
  3. Factor monolithic application into microservices and test

Part B: Deploy microservices leveraging:

  1. Cloud Foundry
  2. Kubernetes Cluster
  3. Istio
  4. OpenWhisk

After you deployed Flightassist using any platform, you can go to How to Use Flightassist and start testing your application.

1. Create your Cloudant Database and Insights for Weather Service

First, clone and get in our repository to obtain the necessary files and scripts for building this example.

git clone https://github.com/IBM/Microservices-deployment-with-PaaS-Containers-and-Serverless-Platforms.git && cd Microservices-deployment-with-PaaS-Containers-and-Serverless-Platforms

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 myweatherinsights

Before 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 key-create mycloudant {service key} #You can put any name for 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

2. Deploy monolithic Flightassist application using Cloud Foundry

In this scenario, we will deploy Flightassist as a monolithic application and host it on Cloud Foundry.

First, type the following commands to push your application with your own unique application name.

bx app push {your_unique_app_name} -f main_application/manifest.yml

Note: If you want to use cf commands, please install cloudfoundry CLI and run cf push {your_unique_app_name} -f main_application/manifest.yml

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 FlightStats
  • FLIGHTSTATS_APP_KEY : application key assigned by FlightStats
  • TRIPIT_API_KEY : API key assigned by TripIt
  • TRIPIT_API_SECRET : API secret assigned by TripIt
  • BASE_URL: your URL for accessing your application. e.g. https://{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.

Congratulations, now you can learn about How to Use Flightassist and start testing your application.

3. Factor monolithic application into microservices and test

To factor the application into microservices, we add a python microservice to the picture. Instead of directly accessing the apis from Node app, the python program will serve as a proxy to query. This step locally tests the app with the microservice and associated docker container images which are created.

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. Create a key for the weather service and then run the following commands to view the service urls.

bx service key-create myweatherinsights {service key} #You can put any name for your {service key}
bx service keys {service_name} #This will output all your service keys for the {service_name}
bx service key-show {service_name} {service key} #This will output your service credential, "url" is Your service URL

Then, run the following commands to build your docker images and run Docker Compose.

docker build -f main_application/Dockerfile.local -t flightassist main_application
docker build -f flightassist-weather/Dockerfile.alpine -t weather-service flightassist-weather
docker-compose up

Now, your FlightAssist application should be running on http://localhost:3000/

Deploy leveraging different scenarios

Now you know to deploy your application and microservices on your local host. So let's deploy your application and microservice on the cloud with these 4 different scenarios.

  1. Cloud Foundry
  2. Kubernetes Cluster
  3. Istio
  4. OpenWhisk

How to Use Flightassist

To try out Flightassist, you need to add a trip on TripIt. Then, add at least one flight for your trip with a departure within the next 24 hours. In your plan, please fill in your confirmation number or airline with flight number.

Tripit plan

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.

Flightassist status

Reference

This project is based on this flightassist example.

Phil Estes and Lin Sun are the main contributors for the flightassist example.

License

Apache 2.0

About

PaaS platforms like Cloud Foundry, container orchestrators like Kubernetes, Serverless platforms like OpenWhisk and Service-mesh like Istio are all great technologies to deploy and manage your microservices on. In this code we look at deployment experience the different platforms provide, and what do we gain and loose by choosing one vs another.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published