Containerization¤
ASAB is designed for deployment into containers such as LXC/LXD or Docker. ASAB allows you to build microservices that provide REST APIs or consume MQ messages while being deployed into a container for the sake of the infrastructure flexibility.
Running ASAB in a LXC/LXD container¤
-
Prepare LXC/LXD container based on Alpine Linux
-
Swich into a container
-
Prepare Python3 environment
-
Deploy ASAB
-
Deploy dependencies
-
Use OpenRC to automatically start/stop ASAB application
Adjust the example of OpenRC init file.
Docker Remote API¤
In order for ASAB applications to read the Docker container name as well as other information related to the container to be used in logs, metrics, and other analysis, the Docker Remote API must be enabled. To enable the Docker Remote API:
-
Open the Docker service file:
-
Find the line which starts with
ExecStart
and add-H=tcp://0.0.0.0:2375
. - Save the file.
-
Reload the Docker daemon and restart the Docker service:
Then in the ASAB application's configuration, provide the Docker Socket path in
docker_socket
configuration option:
Thus, the metric service as well as log manager can use the container name as hostname instead of container ID, which provides better readability when analyzing the logs and metrics, typically when using InfluxDB and Grafana.