Development, Test and Production

This document describes:

  • How to setup the development/test environment for this project;
  • How to release it as a standalone application, run it with docker-compose.

Prerequisite for Development, Test and Production

This is a NodeJS project, implemented with TypeScript, applied LoopBack 4 framework to provide RESTful APIs.

To run or test it, you need to install the following dependencies in your sandbox.

Development/Test

Setup:

Follow the steps to setup your developing/testing sandbox.

  1. Fork this code repository to your own repository.
  2. Clone your repository to local sandbox.
  3. Change directory to <localrepo>/app/waf.
  4. Run command npm install to install all package dependencies.

Development:

  • Source codes are under <localrepo>/app/waf/src.
  • Use your preferred IDE(VIM or VSCode) for the development.

VSCode is recommended because it’s easy to debug the typescript after setting proper launch.json and tasks.json for the debug. See Debugging in VSCode.

  • Manually testing requires a set of containers to be started: ASG, DO and POSTGRES.

Refer to the docker-compose command from Run ADCaaS as Standalone Application of this document.

Test:

The testing code(include acceptance and unit test) is under <localrepo>/app/waf/test.

  1. Run npm run prettier:fix && npm run build to compile it.

npm run prettier:fix is to apply tslint to the code.

  1. Run npm test to to trigger all test cases.
  2. Run npm run coverage to check the code coverages.

The code coverage should be fulfilled before check in.

More details about development and test, see <localrepo>/app/waf/packages.json.

Production

ADCaaS is supported to be released as a docker image which users can pull from a docker repository.

The docker repository is owed by either users themselves or F5Networks.

Release Docker Image Locally

  1. Go to folder <localrepo>/app/waf, where locates the Dockerfile.
  2. Run docker build command mentioned in <localrepo>/app/waf/Dockerfile.

docker build . -t f5devcentral/f5-openstack-services:latest

Note that: Change f5devcentral/f5-openstack-services to your own [repo/tag:version].

Publish ADCaaS Image To Docker Repository

Run docker push [repo/tag:version] to push your generated image to the public repository(after docker login).

Run ADCaaS as Standalone Application

You can use <localrepo>/scripts/start_all.sh to start all. The script is responsible for:

  1. run the container initialization.
  2. enable environment settings.
  3. run docker-compose up -d -f <localrepo>/deploy/docker-compose.yml to start ADCAAS container and its dependent containers, see that docker-compose.yml file.

Note: on MacOSX, running start_all.sh may get the error: ERROR: for ASG  Cannot start service ASG: Mounts denied:       The path /var/tmp/ASGExtensions is not shared from OS X and is not known to Docker.       You can configure shared paths from Docker -> Preferences... -> File Sharing.       See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info. Solution: Add /var/tmp(better) or /var/tmp/ASGExtensions to the settings as it mentions.

Note that for development and test, the ADCAAS container should be stopped and removed since we run ADCaaS application locally instead of the container. Use docker rm --force ADCAAS to remove it after docker-compose up -d.

Logging/Support

EFK

We use Elasticsearch + Fluentd + Kibana stack to make logging analysis, collection and visulization scalable, flexible and easy to use.

Setup

We have already included the auto deployment in docker compose'. After running 'start_all.sh, run docker ps to check the containers. Images of EFK described above should be present.

Browse

In order to read logs, follow the instruction below.

  1. With a browser, go to the Kibana port address (aka. http://localhost:5601/) listed by running docker ps.
  2. Press Discover on the left and you will be prompted to create index pattern.
  3. Define Index pattern as fluentd-*. Success! Your index pattern matches # index. following a tick should show up. Press Next step.
  4. Select @timestamp in Time Filter field name and press Create index pattern.
  5. After configuring an index pattern, you can go to Discover to view the logs.

Request ID

Sometimes when there are multiple processes running, it is likely that logs for them are mixed together, causing diagnosis difficult. To deal with this scenario, we have incorporated the request ID generated by each unique api call in logs it triggers. IDs are enclosed in [] together with the name of component generating the log, indicated in the beginning of each log message. Users of F5 ADCaaS and EFK can filter logs by request ID as following:

  1. Upon making an api call successfully, a piece of log should read Authentication OK: Request ID followed by the id. Save this information.
  2. In Kibana Discover search bar, type message: followed by the request ID enclosed in quotation marks (e.g. message: "9a8d2730-ad33-11e9-b5c0-d312442f5dc4") and press Update.