Skip to content

Manager

Oskar Liew edited this page Dec 1, 2021 · 2 revisions

The Daeploy Manager application contains an API that lets users create and manage services, manage notifications and contains a dashboard to show running services. The schematic above shows the overall architecture of the manager.

Runtime Connector

This is the heart of the application that manages all the low level service operations. The runtime connector is designed to be able to support multiple different backends, but for now there only exists a LocalDockerConnector. The docker connector uses docker-py to programmatically perform docker operations. It is used to list, create, delete, inspect services as well as fetch logs from services and the manager itself. The logs method is asynchronous to make it possible to get the logs in real time.

Databases

The manager contains an SQLite database to store information about services, users and tokens. SQLite is convenient because the database is stored as a file without the need to run it as a separate server. To connect and interact with the database we use SQLAlchemy which protects us from SQL injection attacks and lets us define database tables programmatically in python.

Auth Database

The auth database contains information about the users and authorization tokens.

Config Database

The config database is used to set a JWT token secret that is used for encryption and decryption of authorization tokens.

Service Database

The service database contains information about all the services running on the manager. Each service also gets a unique authorization token that allow services to communicate with each other.

API Routers

The manager API is split into a number of API routers that each define a set of related API endpoints.

Admin API

The admin API is used to manage users and can only be used by the Admin user. It uses the auth database for user management and the JWT token from the config database to decode the caller's token to verify that it is the admin user.

Auth API

The auth API is used to handle logins and authorization tokens. It uses the auth database for managing tokens and passwords and the JWT token from the config database to encode and decode tokens.

Dashboard API

Uses plotly dash to build a dashboard to show running services and notifications.

Logging API

The logging API exposes the manager logs from the runtime connector to an API endpoint.

Notification API

The notification API handles all the manager notifications.

Service API

The service API defines all the endpoints for creation and management of services. It takes the methods from the realtime connector and exposes them to the API. This part of the code is also responsible for the creation of images using Source-To-Image that are then deployed using the realtime connector.

License

The license module is used for managing licenses for Daeploy, like activating new licenses and restricting access for expired licenses.

FastAPI App

This is the main file of the program and it contains the FastAPI App that contains the API defined in the routers. Here we also register proxy and databases to start at service startup.

Proxy

For the proxy we use an open source edge router called Traefik. We use the proxy to route services deployed as docker containers on different ports to unique URLs. Traefik is configured using TOML files and consist of a static configuration file that doesn't change during runtime and a number of dynamic configuration files that we can add, remove and modify during runtime. The dynamic configuration files set up rules for rl routing, configures mirroring to allow for shadow deployment and sets up HTTPS for the manager. The proxy is started as a subprocess in the manager container on application startup.