TIDBIT
Introduction
In Technology, or for an IT department, the Digital Business Agility means to have a flexible Platform Enterprise “Core”.
Your Core is represented by all technological building blocks that are used as a foundation on top of which a large number of innovative services or products can be developed.
SOAJS allows you to achieve digitization without any barrier
Framework Freedom | Do not disrupt engineers by imposing new framework. This will kill agility |
---|---|
API Management & Lifecycle | Build homogen API catalog by leveraging what you have. Do not start from scratch |
Multitenant API | Create economy of scale and accelerate time to market. Reusability is profitability |
Agnostic Container Technology | Do not limit yourself to proprietary technologies. Take advantage of kubernetes, swarm and other container technologies. |
Agnostic Cloud | Leverage any cloud provider as well as you own private cloud. Move any system you have on the cloud in minutes |
Continuous Integration & Delivery | Release with a click of button. Speed Speed Speed |
Objective
Demonstrate how SOAJS:
- Integrate, Activate & Deploy a distributed service oriented architecture SOA cooked up from different technologies ( HAPI - Express - Java )
- Integrate & Activate ( with Github )
- Container Technology ( via Docker Swarm )
- Cloud Orchestration ( via SOAJS Dashboard )
- Apply API Management & Lifecycle on SOA
- Turning on Multi-Tenancy
- Configuring and apply Multi-Security
- Configuring and using Multi-Tenancy (at code level)
- Manage your SOA using the API Catalog Module ( via Swagger )
- Turn on Continuous Integration & Delivery ( with Travis )
Scenario
- Show Case Explained
- Services
- Productization
- Multitenancy
- SOAJS Layers
- Steps
- Turn on Continuous Integration & Delivery
Show Case Explained
Our Demo will demonstrate how to deploy an environment ( DEV ) then deploy 3 services in it where each service is built using a certain technology/framework.
Once deployed, we will show using the Swagger Simulator tool in the API Catalog Module:
- how to test the APIs of these services
- how multi tenancy is applied at the code level
- how mutli security is applied on running services
Finally we will demonstrate how to turn on Continuous Integration & Delivery, configure it and see it in action.
Services
Our Demo introduces 3 services each having 2 APIs: JAVA - Express - Hapi
We will show how to integrate and deploy these services in the DEV environment and how to invoke their APIs using the Swagger Tool.
Service | API | Method | Description |
---|---|---|---|
Java | /tidbit/hello | POST | retrieve a SOAJS object |
Java | /tidbit/hello | GET | returns a message containing your username and last name. |
Hapi | /tidbit/hello | POST | retrieve a SOAJS object |
Hapi | /tidbit/hello | GET | returns a message containing your username and last name. |
Express | /tidbit/hello | POST | retrieve a SOAJS object |
Express | /tidbit/hello | GET | returns a message containing your username and last name. |
Productization
We will import a ready made configuration that introduces a product with 2 ACL packages where package 1 offers full access to all 3 services and their APIs while package 2 offers limited access to APIs who use the POST method only.
Package Name | Environment | Description |
---|---|---|
package 1 | DEV | provides public access to both APIs |
package 2 | DEV | provides limited access to only POST API |
Mutlitenancy
The ready made configuration also includes 5 tenants who are configured to use the productized packages as follow:
Tenant Name | Code | Package | Description |
---|---|---|---|
TIDBIT 1 | TID1 | package 1 | full access to all the APIs of all the services |
TIDBIT 2 | TID2 | package 1 | full access to all the APIs of all the services |
TIDBIT 3 | TID3 | package 2 | limited access to the API that use the POST method only |
TIDBIT 4 | TID4 | package 2 | limited access to the API that use the POST method only |
TIDBIT 5 | TID5 | package 2 | limited access to the API that uses the GET method only |
The final tenant uses package 2 yet his access is completely different that the 2 tenant above it. The idea here is to show that you can override the default package ACL at the tenant level.
SOAJS Layers
- Users and Groups belong to tenants.
- Tenants use product packages and each tenant offers a custom configuration per environment.
- Products and Packages provide ACL access to services
- Services provide APIs and are deployed in multiple environments.
1. Install SOAJS
Start by installing and deploying SOAJS as a local Cloud; Click Here and you will be redirected to the SOAJS Installer Space where you can find the installation instructions. For this demo, we will be using Local Cloud Deployment on top of Docker.
Use the installer to install SOAJS, but do not login yet, this demo requires you to import some settings then it tell you when it is time to login.
2 - Install Ready Made Demo configuration
Clone the configuration repository from github; it contains the code and a script that will bootstrap some database configuration for this demo ( explained here )
OSX Users
Make sure you have Xcode (or at least Xcode cli) installed to be able to use the "git" command from the terminal!
# Create a directory to clone the repo > mkdir -p /opt/soajs/node_modules # Go to directory > cd /opt/soajs/node_modules # Clone configuration repo from github > git clone git@github.com:soajs/soajs.tidbit.demo # Install the dependencies > cd soajs.tidbit.demo > npm install # node . -h <mongo service host> -p <mongo port> > cd soajs.tidbit.demo/import/ > node . -h dashboard-soajsdata -p 32017
Import Script Help
# Open the import script help manual > cd soajs.tidbit.demo/import/ > node . --help
From here on, we will use the SOAJS Dashboard UI to resume all the work, so log in to the SOAJS Dashboard!!
3 - Integrate & Activate Services
Head over to the Develop pillar → Repositories to activate the microservices.
In the Repositories, we find the default SOAJS account activated and it contains a list of repositories we can turn on and off.
Activate soajs.java.jaxrs_jersey - soajs.nodejs.express and soajs.nodejs.hapi repositories, you will be asked to select a branch; pick master.
4 - Deploy a new Environment
Our import script already imported the configuration we need to get things going. Let's deploy the DEV environment.
Go to Deploy pillar and select DEV from the drop down menu in the top left corner.
Click on Clouds & Deployments in the left-hand side menu , click on the Services tab and press Deploy Environment.
5- Deploy the services ( HAPI - Express - Java )
Navigate to Repositories under Deploy pillar, press on the service you want to deploy, press Configure Deployment and fill the form:
Once the environment is deployed, update your hosts file and add the below entry:
127.0.0.1 dev-api.mydomain.com
Before proceeding, make sure to go to:
Deploy pillar / Clouds & Deployments / Services (tab)
Find the controller entry and click on the 'service Operations' drop down and hit: Reload registry & Load provision
6 - API Catalog
a - Test your Services with Swagger and Postman
We will test the microservice in two ways :
Swagger Simulator: rich UI simulator that provides REST API documentation and the ability to interact with them.
SOAJS Dashboard UI is equipped with Swagger Engine and Simulator by default.- Go to the dashboard → Develop → API Catalog:
- Click on Swagger logo that appears if the microservice contains the property "swagger" set to true
- Choose your environment where you deployed your microservice
- Choose the right tenant TID1 for example
- Use the simulator to make API calls to your microservice
- Postman: simulates your curl requests to test the microservice.
Import the postman collections JAVA.postman_collection.json - EXPRESS.postman_collection.json - HAPI.postman_collection.json from the postman folder in the repo soajs.tidbit.demo you cloned above.
Postman is a GUI platform to make API development faster and easier. Download Postman for your OS here
b- APIs Explanation
- /tidbit/hello using method GET: This API take two parameters, username and lastname. When you hit it, the response is a massage containing the provided username and lastname.
- /tidbit/hello using method POST: This API doesn't take any parameter. When you hit it, a json response is formulated and returned. This json response represents the services configuration that was detected by SOAJS controller and supplied to the service.
This shows that when you use SOAJS, you don't need to modify your code in order to benefit from mutlitenancy and urac.
app.post('/tidbit/hello', function(req, res){ res.send(req.soajs); });
{ "tenant": { "id": "593fdd808428b63b708d5fa6", "code": "TID1", "key": { "iKey": "0e379751d5dda1952d64022bae2324dd", "eKey": "dde502c6bcdfbf87812c6a35788670006d204fda01d3e75354987cfd9a7c3b9b7245cd51aac287703292db0f81a31053fd027f064ddff91e6436910d32cfe06d251aecd60cb2af5e76c51a4eb6b872c9bdcea1a3f965508b3318fcbe2fa44a31" }, "application": { "product": "DEV", "package": "DEV_PACK1", "appId": "58bd240606f3698ba308dc21", "acl": null, "acl_all_env": null, "package_acl": null, "package_acl_all_env": null } }, "servicesConfig": { "data": "This is service config 1" }, "device": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36", "geo": { "ip": "10.255.0.4" } }
By just writing simple express code, SOAJS gave you the power of multitenancy!!
As you see, the API returned all the tenant information with the service config. To learn more about services config, click here.
c- Multitenancy Demonstration
Java, hapi and express are multitenant microservices; you will need to provide the tenant keys for the requests to work.
To find these keys, go to the Manage pillar → Multitenancy → Client ( you will see the list of tenants there ).
Expand a tenant entry, to reach the external keys section, grab the external key and use it in the postman requests. In the Swagger Simulator, when you pick the tenant, the external key is added automatically to the header
Continuous Integration & Delivery
Continuous integration & Continuous Delivery CI/CD provides the mechanism to automate everything. Continuous integration (CI) means that whenever a developer checks in code to the source repository, a build is automatically triggered. Continuous delivery (CD) takes this one step further: after a build and automated unit tests are successful, you automatically deploy the application to an environment where you can do more in-depth testing.
Generally we recommend that you do continuous delivery to your development and staging environments. Most teams, require a manual review and approval process for production deployment.
SOAJS provides you with ready made UI so you can turn on and configure CI/CD with just a few clicks.
Continuous Integration ( Part 1 )
Head to Develop → Continuous Integration and pick the provider you would like to integrate with.
Fill in your account information and enter the CI Yaml Configuration where applicable.
Pick Provider |
---|
Integrate with the provider |
---|
Continuous Integration ( Part 2)
Head to Develop → Repositories and click the configuration button next to your repository and select the Continuous Integration Tab.
Activate your repository and configure its settings and manage the environment variables that should be available at build time.
Activate and Turn CI on Repository |
---|
Continuous Delivery ( Part 1 )
Head to Develop → Repositories and click the configuration button next to your repository.
Select the Continuous Deliver Tab and configure the strategy to use for your service in each environment it is deployed in.
Configure CD on Deployed Repository Service |
---|
Continuous Delivery ( Part 2 )
At this point, CI/CD is turned on and configured for soajs.express repository.
Head back to Develop → Continuous Integration:
- click on Download Continuous Integration
- Extract the zip file and add both files ( .travis.yml & soajs.cd.js ) at the root level of your repository
- Commit and push
Add CI Files to your repository |
---|
CI/CD Full Horizontal Flow
Once CI/CD is configured and the files are in the repository, once a developer pushes updates to the master branch of this repo, the following scenario will take place:
1 | Travis will pick up the change, and run the build operation as instructed by the Yaml Configuration of CI ( Part 1 ) | ||||||
---|---|---|---|---|---|---|---|
2 | Once the build is done and successful
Triggering CD deploy API { //"uri": "http://dashboard-api.soajs.org:80/cd/deploy?deploy_token=yyyyyyyyyyy" "uri": "$SOAJS_CD_DASHBOARD_PROTOCOL://$SOAJS_CD_DASHBOARD_DOMAIN:$SOAJS_CD_DASHBOARD_PORT$SOAJS_CD_DASHBOARD_ROUTE?deploy_token=$SOAJS_CD_DEPLOY_TOKEN", "headers": { "key": "$SOAJS_CD_AUTH_KEY", "Content-Type": "application/json" }, "json": true, "body": { "repo": "soajs.nodejs.express", //repo name "branch": "master", //repo branch //if repo is a service or a multi service, the below get appended to the body "services": [ { "serviceName": "express", //detected repo service "serviceVersion": 1 //detected service version } ] } } | ||||||
3 | The API will load all the deployed services that match the repo name and branch | ||||||
4 | Then based on the CD ( Part 1 ) configuration
|