Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Docker Задание 2
## Настройки Docker и создание скриптов
Для настройки файла контейнера докера воспользуемся следующим конфигом конфигом

![image](assets/images/img.png)

Cоздадим образ на основе файла Dockerfile и контекста:

![image](assets/images/img_1.png)

Конфиг docker-compose файла симулятора выглядит следующим образом:

![image](assets/images/img_4.png)

Конфиг docker-compose файла сервера выглядит следующим образом:

![image](assets/images/img_5.png)

Запустим симулятор через докер:

![image](assets/images/img_6.png)

Загрузим на докер-хаб:

![image](assets/images/img_7.png)

В результате на докер-хабе у нас появится json образ симулятора:

![image](assets/images/img_8.png)

А в самом докере у нас появится новый контейнер temperature:

![image](assets/images/img_9.png)

Запустим контейнер с mosquitto брокером (в результате запуска контейнера с симулятором датчика увидим подключение):

![image](assets/images/img_2.png)

А так же в самом докере появится контейнер с mosquitto брокером:

![image](assets/images/img_12.png)

После запуска симулятора можно будет отследить работу брокера:

![image](assets/images/img_10.png)

## Работа с PlayWithDocker

С помощью команды загрузим все нужные файлы:

```shell
$ git clone -b develop https://github.com/Chilipinas/DockerPractice.git
```
### Клиент (Докер 1)
После запуска simulator.sh скрипта на виртуальной машине развернется три контейнера с разными симуляторами датчиков. Так же автоматически настроится ip route к серверу gateway.

![image](assets/images/img_11.png)

### Шлюз (Докер 2)
После запуска gateway.sh будет настроен путь к двум другим серверам, так же будет запущен контейнер с брокером

![image](assets/images/img_13.png)

### Сервер (Докер 3)
После запуска server.sh будет настроен ip route а так же запущены три контейнера

![image](assets/images/img_14.png)

![image](assets/images/img_15.png)

![image](assets/images/img_16.png)

Настройка базы данных grafana:

![image](assets/images/img_17.png)

Создам три панели с графиками для тока, давления и температуры как на картинке снизу:

![image](assets/images/img_18.png)

Если вывести все графики в один dashboard, то получится следующее:

![image](assets/images/img_19.png)

В конце копируем настройки mqtt.json в файл который будет залит на git.
Binary file added assets/images/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/img_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion vms/client/simulator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.7-alpine
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
Expand Down
12 changes: 6 additions & 6 deletions vms/client/simulator/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ version: "3"

services:
temp_sensor:
image: antonaleks/data-simulator
image: chikomon/sensor-sim
environment:
- SIM_HOST=192.168.1.1
- SIM_HOST=192.168.19.1
- SIM_NAME=TIRCAHL24
- SIM_PERIOD=5
- SIM_TYPE=temperature
pressure_sensor:
image: antonaleks/data-simulator
image: chikomon/sensor-sim
environment:
- SIM_HOST=192.168.1.1
- SIM_HOST=192.168.19.1
- SIM_NAME=PIRCAHL11
- SIM_PERIOD=10
- SIM_TYPE=pressure
current_sensor:
image: antonaleks/data-simulator
image: chikomon/sensor-sim
environment:
- SIM_HOST=192.168.1.1
- SIM_HOST=192.168.19.1
- SIM_NAME=A0_CURRENT
- SIM_PERIOD=1
- SIM_TYPE=current
18 changes: 18 additions & 0 deletions vms/client/simulator/simulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
IpA=192.168.19.10/24
IpB=192.168.19.1
IpC=192.168.8.0/24

echo -e "создаем новый адаптер с типом bridge и делаем связь адаптера с eth0: \n ip link add macvlan1 link eth0 type macvlan mode bridge"
ip link add macvlan1 link eth0 type macvlan mode bridge

echo -e "добавляем ip адрес адаптеру: \n ip address add dev macvlan1 192.168.19.10/24"
ip address add dev macvlan1 $IpA

echo -e "включаем адаптер: \n ip link set macvlan1 up"
ip link set macvlan1 up

echo -e "добавляем маршрут к виртуалке С через виртуалку В: \n ip route add 192.168.8.0/24 via 192.168.19.1"
ip route add $IpC via $IpB

docker-compose up -d
20 changes: 20 additions & 0 deletions vms/gateway/gateway.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
IpB1=192.168.19.1/24
IpB2=192.168.8.1/24


echo -e "создаем новый адаптер с типом bridge и делаем связь адаптера с eth0: \n ip link add macvlan1 link eth0 type macvlan mode bridge"
ip link add macvlan1 link eth0 type macvlan mode bridge
echo -e "добавляем ip адрес адаптеру: \n ip address add dev macvlan1 192.168.19.1/24"
ip address add dev macvlan1 $IpB1
echo -e "включаем адаптер: \n ip link set macvlan1 up"
ip link set macvlan1 up

echo -e "создаем новый адаптер с типом bridge и делаем связь адаптера с eth0: \n ip link add macvlan2 link eth0 type macvlan mode bridge"
ip link add macvlan2 link eth0 type macvlan mode bridge
echo -e "добавляем ip адрес адаптеру: \n ip address add dev macvlan2 192.168.8.1/24"
ip address add dev macvlan2 $IpB2
echo -e "включаем адаптер: \n ip link set macvlan2 up"
ip link set macvlan2 up

docker run -v $PWD/mosquitto:/mosquitto/config -p 1883:1883 --name broker --rm eclipse-mosquitto
Loading