Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Containers vs PAAS vs Serverless

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.

Included Components

The scenarios are accomplished by using:

Prerequisites

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.

Deploy using DevOps Toolchain (In progress)

Click the button to deploy your app and fill in all the variables from Delivery Pipeline and click create.

Create Toolchain

Toolchain Scenarios One: Monolithic Cloud Foundry Application.

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

Toolchain Scenarios Two: Microservices or Serverless with Kubernetes Clusters.

Click View logs and history and access your application via the URL link at the end of your logs.

Steps

  1. Create your Cloudant Database and Insights for Weather Service
  2. Deployment Scenarios

1. Create your Cloudant Database and Insights for Weather Service

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 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

2. Deployment Scenarios

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

Scenario One: Deploy Flightassist on Cloud Platform using Cloud Foundry

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 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: 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.

Scenario Two: Deploy Flightassist as containers using Docker Compose and Kubernetes Clusters

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.

1. Docker Compose

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 URL

Then, 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 up

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

2. Kubernetes Clusters

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 Bluemix

Next, 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 running bx cr namespaces

If you have unauthorized error, run bx cr login to 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-service

Then, 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 myweatherinsights

Next, 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.yaml

Congratulation, 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.

Scenario Three: Deploy Flightassist with Serverless using OpenWhisk

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.yaml

Then, 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.yaml

Congratulation, 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.

How to Use Flightassist

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.

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 contributers 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

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5