Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

NOISSUE - Simplify docker deployment #275

Merged
merged 8 commits into from
Jan 29, 2024
Merged

Conversation

rodneyosodo
Copy link
Member

What type of PR is this?

This is an optimization because it improves docker-compose deployment

What does this do?

It simplifies docker-compose deployment to use one configuration where nats is used as the MQTT broker, Message Broker and Events Store.

Which issue(s) does this PR fix/relate to?

No issue

Have you included tests for your changes?

Yes, I have tested it manually

Did you document any new/modified feature?

Yes, I have added documentation about the deployment

Notes

docker/README.md Outdated
Comment on lines 99 to 93
image: rabbitmq:3.9.20-management-alpine
environment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add container_name for this example.

@arvindh123
Copy link
Contributor

@rodneyosodo
In .env file
we have at present for ES we have :

MG_ES_TYPE=${MG_MESSAGE_BROKER_TYPE}
MG_ES_URL=${MG_NATS_URL}

Instead having ${MG_MESSAGE_BROKER_TYPE} value for env varabileMG_ES_TYPE , Can we have MG_ES_TYPE value as nats/redis,like given below

MG_ES_TYPE=nats
MG_ES_URL=${MG_NATS_URL}

@rodneyosodo
Copy link
Member Author

For now, the Event Store depends on the Message broker apart from when it is Redis. I have changed the env file to reference MG_MESSAGE_BROKER_* and documented when it is redis

docker/README.md Outdated

Events store: This is the same as MESSAGE_BROKER. This can either be 'nats' or 'rabbitmq' or 'redis'. This is used by Magistrala services to store events for distributed processing. If redis is used as an events store, then rabbitmq or nats is used as a message broker.

Since nats is used as both MQTT_BROKER and MESSAGE_BROKER, it is not possible to run nats as an MQTT_BROKER and nats as a MESSAGE_BROKER at the same time, this is the current depolyment strategy for Magistrala in `docker/docker-compose.yml`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this statement. It's used as both MQTT and message broker but, it's not possible to run it as a MQTT and message broker simultaneously. Isn't that contradicting?

docker/README.md Outdated
Magistrala supports configurable MQTT broker and Message broker, which also acts as events store. Magistrala uses two types of brokers:

1. MQTT_BROKER: Handles MQTT communication between MQTT adapters and message broker. This can either be 'vernemq' or 'nats'.
2. MESSAGE_BROKER: Manages communication between adapters and Magistrala writer services. This can either be 'nats' or 'rabbitmq' or 'redis'. This is used to store messages for distributed processing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. MESSAGE_BROKER: Manages communication between adapters and Magistrala writer services. This can either be 'nats' or 'rabbitmq' or 'redis'. This is used to store messages for distributed processing.
2. MESSAGE_BROKER: Manages communication between adapters and Magistrala writer services. This can either be 'nats' or 'rabbitmq'. This is used to store messages for distributed processing.

In the next paragraph you say redis cannot be used as message broker

docker/README.md Outdated

For Message brokers other than nats, you would need to build the docker images with rabbtitmq as the build tag and change the `docker/.env`. For example, to use rabbitmq as a message broker:

```env
Copy link
Contributor

@ianmuchyri ianmuchyri Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this env code, as it is in the one below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@arvindh123 arvindh123 Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is a terminal command, passing with varabiles, So it can be bash, sh or anyother

docker/README.md Show resolved Hide resolved
rodneyosodo and others added 6 commits January 29, 2024 11:11
Signed-off-by: rodneyosodo <[email protected]>
This commit fixes the container name and restart policy for the RabbitMQ service in the docker-compose file. The container name is changed to "magistrala-rabbitmq" and the restart policy is set to "on-failure". This ensures that the RabbitMQ container has a unique and identifiable name and will automatically restart in case of failure.

Signed-off-by: Rodney Osodo <[email protected]>
The system now supports the use of different message brokers and events stores by modifying the docker environment variables and updating the `.env` file. This allows for easy integration of alternative options such as RabbitMQ as the message broker.

Signed-off-by: Rodney Osodo <[email protected]>
Updates the NATS and RabbitMQ URLs in the .env file to reflect the latest configurations. The README.md file is also updated to include information about the Magistrala services using an events store and lists the available options.

The docker-compose.yml file is modified to include the current deployment strategy for Magistrala. It now includes configurations for the MQTT broker, message broker, and events store.

The provided YAML snippet contains RabbitMQ configuration for a Docker Compose setup.

Additionally, a configuration file for the Docker container "vernemq" and a network called "magistrala-base-net" are mentioned in the summary.

Signed-off-by: Rodney Osodo <[email protected]>
Signed-off-by: Rodney Osodo <[email protected]>
docker/README.md Outdated
1. MQTT_BROKER: Handles MQTT communication between MQTT adapters and message broker. This can either be 'VerneMQ' or 'NATS'.
2. MESSAGE_BROKER: Manages communication between adapters and Magistrala writer services. This can either be 'NATS' or 'RabbitMQ. This is used to store messages for distributed processing.

Events store: This is the same as MESSAGE_BROKER. This can either be 'NATS' or 'RabbitMQ' or 'Redis'. This is used by Magistrala services to store events for distributed processing. If Redis is used as an events store, then RabbitMQ or NATS is used as a message broker since Redis cannot be used as a message broker.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with something like: By default, we are using the same broker for messages and events. You can also remove it since it's already mentioned above.

docker/README.md Outdated
Magistrala supports configurable MQTT broker and Message broker, which also acts as an events store. Magistrala uses two types of brokers:

1. MQTT_BROKER: Handles MQTT communication between MQTT adapters and message broker. This can either be 'VerneMQ' or 'NATS'.
2. MESSAGE_BROKER: Manages communication between adapters and Magistrala writer services. This can either be 'NATS' or 'RabbitMQ. This is used to store messages for distributed processing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not only writers but any internal consumer. Manages message exchange between Mainflux core, optional, and external components.

docker/README.md Outdated
MG_ES_URL=${MG_REDIS_URL}
```

For MQTT broker other than NATS, you would need to change the `docker/.env`. For example, to use VerneMQ as a MQTT broker:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make VerneMQ a default MQTT broker.

@dborovcanin dborovcanin merged commit 562c578 into absmach:main Jan 29, 2024
4 checks passed
@rodneyosodo rodneyosodo deleted the compose branch January 30, 2024 09:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants