Skip to content

Commit

Permalink
Merge pull request #3 from qiot-project/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
andreabattaglia authored Apr 17, 2021
2 parents a4b0d23 + e749548 commit 06d125b
Show file tree
Hide file tree
Showing 17 changed files with 479 additions and 343 deletions.
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
## qiot-datahub-docker

A set od docker-compose files to run the QIoT environment on your host machine using a OCI-compliant container engine and tools.
Podman engine is recommendedthus you'll find below the prerequisited and mandatory actions to take before using these compose files:
Podman engine is recommended, thus you'll find below the prerequisites and mandatory actions to take before using these compose files:

# if you want to go with podman:

`$ sudo dnf install -y podman podman-compose`

# Set up a dedicated container network for both your edge pods and datahub pods


`$ sudo docker network create edge` - Network dedicated to the services running on the edge device
/etc/cni/net.d/qiot-covid19-edge.conflist

`$ sudo podman network create datahub` - Network dedicated to the services running on the datacenter
`$ sudo docker network create datahub` - Network dedicated to the services running on the datacenter
/etc/cni/net.d/qiot-covid19-datahub.conflist

`$ sudo docker network create qiotconnect` - Network dedicated to the interaction between the edge device and the datahub
Expand All @@ -33,7 +32,7 @@ Podman: Podman Cockpit extension

We can edit the `/etc/selinux/config` text file with our persistent setting, either enforcing, permissive, or disabled. By default this file appears as shown below.

```
```properties
This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
Expand All @@ -47,4 +46,55 @@ ELINUXTYPE= can take one of three two values:
SELINUXTYPE=targeted
```

We can simply edit the SELINUX variable between enforcing, permissive, or disabled, as outlined in the comments of the file. After editing the file the changes will not be in place immediately and will only change after system reboot.
We can simply edit the SELINUX variable between enforcing, permissive, or disabled, as outlined in the comments of the file. After editing the file the changes will not be in place immediately and will only change after system reboot.

# The QIoT-covid19 system

The QIoT covid19 use-case implementation is made up of 3 main layers:

- **comp**: the software infrastructure, composite of integration products to make micro-services interact with each other and to manage endpoints and data
- **datahub**: micro-services implementing the use-case business logic
- **edge**: software running at the edge device
- **sensors**: a micro-service emulating the behavior of the sensor board connected to the raspberry pi
- **edge**: the micro-service implementing the edge device business logic

## Spinning up the environment

Just enter each and every folder and run a docker compose or, alternatively, use Portainer.io to manage your stacks.

Please follow the order below to make sure all the components are capable to find their dependencies accordingly:

### software architecture

```bash
$ cd comp
$ docker-compose up --remove-orphans
```

​ access the mysql instance and execute the script contained in the file *mysql-setup.sql*:


```bash
$ docker exec -it mysql bash -l
```

### business logic

```bash
$ cd datahub
$ docker-compose up --remove-orphans
```

### edge device - sensors

```bash
$ cd edge/sensors
$ docker-compose up --remove-orphans
```

### edge device - business logic

```bash
$ cd edge/application
$ docker-compose up --remove-orphans
```
29 changes: 14 additions & 15 deletions buildQiot.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
cd /home/abattagl/git/qiot/datahub/qiot-datahub-storer/qiot-datahub-storer-gas/
cd ~/git/qiot/datahub/qiot-datahub-localization/
chmod +x build.sh
./build.sh
cd /home/abattagl/git/qiot/datahub/qiot-datahub-storer/qiot-datahub-storer-pollution/
cd ~/git/qiot/datahub/qiot-datahub-station/
chmod +x build.sh
./build.sh
cd /home/abattagl/git/qiot/datahub/qiot-datahub-aggregation/
cd ~/git/qiot/datahub/qiot-datahub-registration/
chmod +x build.sh
./build.sh
cd /home/abattagl/git/qiot/datahub/qiot-datahub-query/
cd ~/git/qiot/datahub/qiot-datahub-collector/
chmod +x build*.sh
./buildgas.sh
./buildpollution.sh
cd ~/git/qiot/datahub/qiot-datahub-storer/
chmod +x build*.sh
./buildgas.jvm.sh
./buildpollution.jvm.sh
cd ~/git/qiot/datahub/qiot-datahub-importer/
chmod +x build.sh
./build.sh
cd /home/abattagl/git/qiot/datahub/qiot-datahub-importer/
chmod +x build.sh
./build.sh
cd /home/abattagl/git/qiot/datahub/qiot-datahub-registration/
chmod +x build.sh
./build.sh
cd /home/abattagl/git/qiot/datahub/qiot-datahub-endpoint/qiot-datahub-endpoint-mqtt/
chmod +x build.sh
./build.sh
#cd /home/abattagl/git/qiot/edge/qiot-sensors-emulator/
#cd ~/git/qiot/edge/qiot-sensors-emulator/
#chmod +x build.sh
#./build.sh
#cd /home/abattagl/git/qiot/edge/qiot-service/
#cd ~/git/qiot/edge/qiot-service/
#chmod +x build.sh
#./build.sh

1 change: 0 additions & 1 deletion comp/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
/volumes/
122 changes: 69 additions & 53 deletions comp/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,79 +1,95 @@
version: '3'
services:
activemq:
image: vromero/activemq-artemis:2-alpine-latest
container_name: "activemq"
restart: "no"

mosquitto:
image: eclipse-mosquitto:1.6.2
container_name: "mosquitto"
restart: "always"
networks:
- datahub
- qiotconnect
ports:
- "8161:8161"
# - "61616:61616"
# - "5672:5672"
- "1883:1883"
environment:
ARTEMIS_USERNAME: "quarkus"
ARTEMIS_PASSWORD: "quarkus"
# kafdrop:
# image: obsidiandynamics/kafdrop
# container_name: "kafkadrop"
# restart: "no"
# ports:
# - "9000:9000"
# environment:
# KAFKA_BROKERCONNECT: "kafka:29092"
# JVM_OPTS: "-Xms16M -Xmx48M -Xss180K -XX:-TieredCompilation -XX:+UseStringDeduplication -noverify"
# depends_on:
# - "kafka"
- "1883:1883"
- "9001:9001"

kafka:
image: obsidiandynamics/kafka
container_name: "kafka"
restart: "no"
restart: "always"
ports:
- "2181:2181"
- "9092:9092"
environment:
KAFKA_LISTENERS: "INTERNAL://:29092,EXTERNAL://kafka:9092"
KAFKA_LISTENERS: "INTERNAL://:29092,EXTERNAL://:9092"
KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka:29092,EXTERNAL://kafka:9092"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT"
KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL"
KAFKA_ZOOKEEPER_SESSION_TIMEOUT: "6000"
KAFKA_RESTART_ATTEMPTS: "10"
KAFKA_RESTART_DELAY: "5"
ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL: "0"
mongo:
image: "mongo"
container_name: "mongo"

postgresql:
image: postgres
container_name: "postgresql"
restart: always
ports:
- "5432:5432"
volumes:
- postgres-storage:/var/lib/postgresql/data
environment:
MONGO_INITDB_DATABASE: "qiot"
#MONGO_INITDB_ROOT_USERNAME: "root"
#MONGO_INITDB_ROOT_PASSWORD: "root"
POSTGRES_USER: "qiot"
POSTGRES_PASSWORD: "qiot"
POSTGRES_DB: "qiot"

postgresqladminer:
image: adminer
container_name: "postgresqladminer"
restart: always
ports:
- "18080:8080"

influxdb:
image: "influxdb:latest"
container_name: "influxdb"
ports:
- "8086:8086"
- "9999:9999"
volumes:
#- ./init-mongo.js: /docker-entrypoint-initdb.d/init-mongo.js:ro
- ./volumes/mongo:/data/db
- influxdb-user-storage:/root/.influxdbv2
- influxdb-data-storage:/var/lib/influxdb2
- influxdb-config-storage:/etc/influxdb2
environment:
DOCKER_INFLUXDB_INIT_MODE: "setup"
DOCKER_INFLUXDB_INIT_USERNAME: "qiot"
DOCKER_INFLUXDB_INIT_PASSWORD: "qiotcovid19password"
DOCKER_INFLUXDB_INIT_ORG: "qiot"
DOCKER_INFLUXDB_INIT_BUCKET: "covid19"
# DOCKER_INFLUXDB_INIT_RETENTION: The duration the system's initial bucket should retain data. If not set, the initial bucket will retain data forever
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: "qiotcovid19influxdbtoken"

grafana:
image: "grafana/grafana"
container_name: "grafana"
links:
- influxdb
ports:
- "27017-27019:27017-27019"
# mongo-express:
# image: mongo-express
# container_name: mongo-express
# environment:
# ME_CONFIG_MONGODB_SERVER: "mongo"
# ME_CONFIG_MONGODB_PORT: "27017"
# #ME_CONFIG_MONGODB_ENABLE_ADMIN: "false"
# #ME_CONFIG_MONGODB_AUTH_DATABASE: "qiot"
# #ME_CONFIG_MONGODB_AUTH_USERNAME: "qiot"
# #ME_CONFIG_MONGODB_AUTH_PASSWORD: "qiot"
# ports:
# - "8081:8081"
# influx:
# image: "quay.io/influxdb/influxdb:v2.0.3"
# container_name: "influx"
# volumes:
# - ./volumes/influxdb2:/root/.influxdbv2
# ports:
# - "8086:8086"
# - "9999:9999"
- "3000:3000"
volumes:
- grafana-storage:/var/lib/grafana
- ./volumes/grafana/provisioning:/etc/grafana/provisioning
depends_on:
- influxdb
environment:
GF_SECURITY_ADMIN_USER: "qiot"
GF_SECURITY_ADMIN_PASSWORD: "qiot"

volumes:
influxdb-user-storage:
influxdb-data-storage:
influxdb-config-storage:
grafana-storage:
postgres-storage:
networks:
datahub:
external: true
Expand Down
15 changes: 0 additions & 15 deletions comp/init-mongo.js

This file was deleted.

9 changes: 9 additions & 0 deletions comp/volumes/grafana/provisioning/dashboards/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1
providers:
- name: InfluxDB
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards
11 changes: 11 additions & 0 deletions comp/volumes/grafana/provisioning/datasources/datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1
datasources:
- name: InfluxDB
type: influxdb
access: proxy
database: qiot
user: qiot
password: qiot
url: http://influxdb:8086
isDefault: true
editable: true
Loading

0 comments on commit 06d125b

Please sign in to comment.