/serverless-iot

Serverless architectural design for IoT systems

Primary LanguageJavaScriptMIT LicenseMIT

Serverless architectural design for IoT systems

Prerequisites

  1. Install Docker CE for Ubuntu here
  2. Install Docker CE for Raspbian here
  3. Install faas-cli. Instructions here
  4. Python3 installed with the yml module (this is used to create the configuration files)

Basic Instalation

  1. Template for my_rig_config.json
{
    "name": "pi001",
    "maxCapacity": 1001,
    "thing": true,
    "localUrl": "http://192.168.78.1",
    "localPort": 8080,

    "serverUrl": "http://192.168.78.130",
    "serverPort": "8080",
    "prometheusPort":9090,
    "write_timeout": 10,
    "read_timeout": 10,
    "mongo": "openfaas-db-mongodb"

}
  1. Clone the openfaas repository
$ git clone https://github.com/openfaas/faas && \
  cd faas && \
  git checkout 0.7.7 && \
  cd ..
  1. Initiate a docker swarm. In some cases, the flag --advertise-addr might be needed to specify the advertised address.
$ sudo docker swarm init
  1. Deploy faas and remove unnecessary functions that come preinstalled.
$ sudo ./deploy_faas.sh
  1. Continue instalation process process for IoT swarm or Cloud swarm

(Cont.) Instalation for local swarm (IoT)

  1. Create a mongodb Docker Service
$ docker service create --network=func_functions --name openfaas-db-mongodb --publish 27017:27017 mongo mongod
  1. Create configuration files
$ python3 create_my_functions.py sample-functions/stack.yml
  1. Deploy my functions.
$ sudo ./deploy_my_functions.sh

(Cont.) Instalation in the cloud swarm (Server)

  1. Create configuration files
$ python3 create_my_functions.py sample-functions/stack.yml
  1. Deploy my functions.
$ sudo ./deploy_my_functions.sh --server