sonata-nfv / tng-gtk-sp

The 5GTANGO Gatekeeper Service Platform specific components repository
1 stars 7 forks source link
5g 5gtango gatekeeper service-platform sonata

Build StatusJoin the chat at https://gitter.im/sonata-nfv/Lobby

Service Platform-specific Gatekeeper component

This is the 5GTANGO Gatekeeper Service Platform specific components repository, which implements the Gatekeeper features that are specific to the 5GTANGO Service Platform.

For details on the overall 5GTANGO architecture please check here. The Gatekeeper is the component highlighted in the following picture.

You might also be interested in the following related repositories:

Supported endpoints

Supported endpoints, alphabetically sorted, are described next. These endpoints are internal, only the ones exposed by the router in the Service Platform's and V&V Platform's routing files are available from the outside.

Endpoints Description
/ The root of the API.
/pings The module's readiness and liveness endpoint
/policies Manages placement and run-time policies
/records/functions Lists function records available in the Repository
/records/services Lists service records available in the Repository
/requests Manages services' and slices' lifecycle events (creation, scaling, deletion, etc.)
/slices Manages slice templates

Installing / Getting started

This component is implemented in ruby, version 2.4.3.

Installing from code

To have it up and running from code, please do the following:

$ git clone https://github.com/sonata-nfv/tng-gtk-sp.git # Clone this repository
$ cd tng-gtk-sp # Go to the newly created folder
$ bundle install # Install dependencies
$ PORT=5000 bundle exec rackup # dev server at http://localhost:5000

Note: See the Configuration section below for other environment variables that can be used.

Everything being fine, you'll have a server running on that session, on port 5000. You can aesscc it by using curl, like in:

$ curl <host name>:5000/

Installing from the Docker container

In case you prefer a docker based development, you can run the following commands (bash shell):

$ docker network create tango
$ docker run -d -p 27017:27017 --net=tango --name mongo mongo
$ docker run -d -p 5432:5432 --net=tango --name postgres postgres
$ docker run -d -p 5672:5672 --net=tango --name rabbitmq rabbitmq
$ docker run -d -p 4011:4011 --net=tango --name tng-cat sonatanfv/tng-cat:dev
$ docker run -d -p 4012:4012 --net=tango --name tng-rep sonatanfv/tng-rep:dev
$ docker run -d -p 5000:5000 --net=tango --name tng-gtk-sp \
  -e CATALOGUE_URL=http://tng-cat:4011/catalogues/api/v2 \
  -e REPOSITORY_URL=http://tng-cat:4012 \
  -e MQSERVER_URL=amqp://guest:guest@rabbitmq:5672 \
  -e POSTGRES_PASSWORD=tango \
  -e POSTGRES_USER=tangodefault \
  -e DATABASE_HOST=postgres \
  -e DATABASE_PORT=5432 \
  sonatanfv/tng-gtk-sp:dev

Note: user and password are mere indicative, please choose the apropriate ones for your deployment.

With these commands, you:

  1. Create a docker network named tango;
  2. Run the MongoDB container within the tango network;
  3. Run the PostgreSQL container within the tango network;
  4. Run the RabbitMQ container within the tango network;
  5. Run the Catalogue container within the tango network;
  6. Run the Repository container within the tango network;
  7. Run the SP-specific Gatekeeper container within the tango network, with the needed environment variables set to the previously created containers.

Developing

This section covers all the needs a developer has in order to be able to contribute to this project.

Dependencies

We are using the following libraries (also referenced in the Gemfile file) for development:

The following gems (libraries) are used just for tests:

These libraries are installed/updated in the developer's machine when running the command (see above):

$ bundle install

Prerequisites

We usually use rbenv as the ruby version manager, but others like rvm may work as well.

Setting up Dev

Developing this micro-service is straightforward with a low amount of necessary steps.

Routes within the micro-service are defined in the config.ru file, in the root directory. It has two sections:

This new or updated route can then be mapped either into an existing controller or imply writing a new controller. This new or updated controller can use either existing or newly written services to fullfil it's role.

For further details on the micro-service's architecture please check the documentation.

Submiting changes

Changes to the repository can be requested using this repository's issues and pull requests mechanisms.

Versioning

The most up-to-date version is v4. For the versions available, see the link to tags on this repository.

Configuration

The configuration of the micro-service is done through the following environment variables, defined in the Dockerfile:

Tests

Unit tests are defined for both controllers and services, in the /spec folder. Since we use rspec as the test library, we configure tests in the spec_helper.rb file, also in the /spec folder.

These tests are executed by running the following command:

$ bundle exec rspec spec

Wider scope (integration and functional) tests involving this micro-service are defined in tng-tests.

Style guide

Our style guide is really simple:

  1. We try to follow a Clean Code philosophy in as much as possible, i.e., classes and methods should do one thing only, have the least number of parameters possible, etc.;
  2. we use two spaces for identation.

API Reference

We have specified this micro-service's API in a swagger-formated file. Please check it there.

Licensing

This 5GTANGO component is published under Apache 2.0 license. Please see the LICENSE file for more details.

Feedback-Channel