-
Notifications
You must be signed in to change notification settings - Fork 56
Core udmi services integration stage two #1204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 20 commits
9d0b550
fa2ad6e
f31d97f
7fb3b4b
d2e2e2b
14da854
4cb9b69
0200991
ea2d408
0237c08
002bb11
482f5b0
82886ed
0cb1638
a1538cd
51a4284
3edd59a
5fa88ca
0f4c257
1d5e65d
5ab7eef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,62 @@ | ||
| # MQTT Broker Environment Setup | ||
| # Core UDMI Services Environment Set Up | ||
|
|
||
| This guide provides instructions for deploying and verifying the **Mosquitto MQTT broker** using Docker Compose. | ||
| This guide provides instructions for deploying the core UDMI services bundle. This bundle includes: | ||
| - Mosquitto broker | ||
| - etcd server | ||
| - udmis service | ||
| - validator (registrar) tool | ||
| - pubber tool | ||
|
||
|
|
||
| ### Broker access details | ||
| ## Setting up the Docker environment | ||
|
|
||
| - **Broker address**: The host machine's local IP address (e.g., `localhost` or `127.0.0.1`). | ||
| - **Port**: `1883` | ||
| 1. **Install docker engine:** Ensure Docker is installed and running on your system: `https://docs.docker.com/engine/install/` | ||
|
|
||
| The configuration is designed for connections without client credentials. | ||
| 2. **Navigate to project directory:** Open your terminal and change the directory to the project root containing the `docker-compose.yml` file (`bridgehead/`). | ||
|
|
||
| ### Setting up the docker environment | ||
| 3. **Get default site model:** In you terminal, run `sudo git clone https://github.com/faucetsdn/udmi_site_model.git`. | ||
|
|
||
| 1. **Install docker engine:** Ensure Docker is installed and running on your system: `https://docs.docker.com/engine/install/` | ||
| 4. **Add your host ip:** Open the docker-compose.yml file and locate the line `HOST_IP: <YOUR_IP>` inside the mosquitto service block. Replace `<YOUR_IP>` with your hosts ip address. You can find this by running `sudo hostname -I`. If you do not plan on using pubber outside of the docker container, you can remove the environment option from the compose file. | ||
|
|
||
| 2. **Navigate to project directory:** Open your terminal and change the directory to the project root containing the `docker-compose.yml` file (`bridgehead/`). | ||
|
|
||
| 3. **Deploy the service:** Execute the following command to build the custom image (if needed) and start the Mosquitto container in detached mode. | ||
| 5. **Deploy the service:** Execute the following command to build the custom images (if needed) and start the containers in detached mode. | ||
| * **First time/after changes:** Run `sudo docker compose up -d --build` | ||
| * **Standard run:** Run `sudo docker compose up -d` | ||
| 6. **Confirm all containers are running:** Run `sudo docker ps` in the terminal, you should see the following containers in any order: | ||
| - pubber | ||
| - validator | ||
| - udmis | ||
| - mosquitto | ||
| - etcd | ||
|
|
||
| ## Tools | ||
|
|
||
| The UDMI tools should only be run after the udmis service has completed setup. You can confirm this by comparing your udmis output to the [sample udmis output](sample_outputs/udmis_output.md). Tools should be run in the same directory as the Docker Compose (`bridgehead/`). | ||
|
|
||
| ### Registrar (validator) | ||
|
|
||
| In your terminal, execute `sudo docker exec validator bin/registrar site_model/ //mqtt/mosquitto`. To confirm a successful execution, take a look at the [sample registrar output](sample_outputs/registrar_output.md) | ||
|
|
||
| ### Pubber | ||
|
|
||
| 4. **Run connectivity check:** Confirm the broker is up and running by executing `sudo docker compose exec mosquitto /usr/local/bin/check_mqtt.sh`. This script performs an internal publish/subscribe self-test. A successful output confirms the broker is fully operational and accepting client connections. | ||
| The pubber tool will only have a successful output after the registrar tool has been executed. This is done by default in compose setup. | ||
|
|
||
| ### Shutting down the docker environment | ||
| #### Local (docker compose) | ||
| - In your terminal, run `sudo docker exec pubber bin/pubber site_model/ //mqtt/mosquitto AHU-1 123456` (`123456` can be replaced with any serial number). | ||
|
|
||
| #### Running pubber on separate machine | ||
| - On your external computer, clone the udmi site model: `sudo git clone https://github.com/faucetsdn/udmi.git`. | ||
| - Export your host ip (the same one we set in the docker compose): `EXPORT HOST_IP=<YOUR_HOST_IP>` | ||
| - Pull your udmi site model, the default is the same we used earlier: `sudo git clone https://github.com/faucetsdn/udmi_site_model.git` | ||
| - Generate keys: `udmi/bin/keygen CA/<YOUR_HOST_IP> udmi_site_model/reflector` and `udmi/bin/keygen CERT/<YOUR_HOST_IP> udmi_site_model/reflector`. | ||
| - Run pubber container: `sudo docker run -d --rm --name externalPubber -v $(realpath udmi_site_model):/root/site_model ghcr.io/faucetsdn/udmi:pubber-latest /bin/bash -c "tail -f /dev/null"` | ||
| - Run pubber: `sudo docker exec externalPubber bin/pubber site_model/ //mqtt/<YOUR_HOST_IP> AHU-1 123456` | ||
|
|
||
| *Note:* You can name the external pubber container anything, as long as it doesn't match of your other containers. I this case, its assumed you will still have the pubber container in the docker compose file, therefore the new container cannot also be called pubber. | ||
|
|
||
| Pubber is running successfully if there are no obvious error messages or retries. An **unsuccessful** run will retry multiple times, will see messages like `Attempt #10 failed`. | ||
|
|
||
| A successful run will not end on its own, you can press `Ctrl` + `C` on your keyboard to exit. | ||
|
|
||
| ## Shutting down the docker environment | ||
|
|
||
| To gracefully stop and remove the container, run: `sudo docker compose down` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,13 @@ | ||
| FROM ghcr.io/faucetsdn/udmi:udmis-latest AS udmi | ||
| FROM eclipse-mosquitto:latest | ||
|
|
||
| COPY check_mqtt.sh /usr/local/bin/ | ||
| RUN chmod +x /usr/local/bin/check_mqtt.sh | ||
| RUN apk add --no-cache bash jq sudo git mosquitto mosquitto-clients openssl sed | ||
|
|
||
| COPY --from=udmi /root/udmi/bin /root/udmi/bin | ||
| COPY --from=udmi /root/udmi/etc /root/udmi/etc | ||
|
|
||
| COPY mosquitto_startup.sh /usr/local/bin/ | ||
| RUN chmod +x /usr/local/bin/mosquitto_startup.sh | ||
|
|
||
| CMD ["/usr/local/bin/mosquitto_startup.sh"] | ||
|
|
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/bin/sh | ||
| UDMI_ROOT=/root/udmi | ||
|
|
||
| function fail { | ||
| echo error: $* | ||
| false | ||
| } | ||
|
|
||
| echo "persistence true | ||
| persistence_file mosquitto.db | ||
| persistence_location /mosquitto/data/ | ||
|
|
||
| include_dir /etc/mosquitto/conf.d" > /etc/mosquitto/mosquitto.conf | ||
|
|
||
| cd $UDMI_ROOT | ||
|
|
||
| site_model=$(realpath /site_model) | ||
| site_config=$site_model/cloud_iot_config.json | ||
| registry_id=$(jq -r .registry_id $site_config) | ||
|
|
||
| source $UDMI_ROOT/etc/mosquitto_ctrl.sh | ||
| mkdir -p $CERT_DIR | ||
|
|
||
| if [[ -n "$HOST_IP" ]]; then | ||
| sed -i -e "s|IP:127.0.0.1,|IP:127.0.0.1, IP:${HOST_IP},|" bin/keygen | ||
| fi | ||
|
|
||
| bin/setup_ca $site_model mosquitto | ||
| bin/start_mosquitto | ||
|
|
||
| $MOSQUITTO_CTRL deleteClient $SERV_USER | ||
| $MOSQUITTO_CTRL createClient $SERV_USER -p $SERV_PASS | ||
| $MOSQUITTO_CTRL addClientRole $SERV_USER service | ||
|
|
||
| echo Starting initializing site $site_model | tee -a $UDMIS_LOG | ||
| bin/mosquctl_site $site_model | ||
|
|
||
| sleep infinity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validator and Registrar, are two different things. Validator is something which can run in the background continuously and validate the messages coming are UDMI compliant or not (so a service), but Registrar is kind of tool which is suppose to run for some time, and after it's work is done, it stops (so, more of a tool) which can be executed from inside the validator container as well.