Environment Configuration
Relevant source files
The following files were used as context for generating this wiki page:
The Environment Configuration for the OdooConnectorAPI defines how the FastAPI application connects to the Odoo ERP backend and manages its operational parameters. This configuration is handled through environment variables, which are consumed by the application code, Docker Compose orchestrations, and Kubernetes Helm charts to ensure consistency across local, containerized, and production environments.
Sources: README.md:39-41, app/main.py:10-13
Application Configuration Variables
The core of the system relies on four primary environment variables used to establish an RPC connection with Odoo via the odoorpc library. These variables allow the API to authenticate and interact with specific Odoo databases.
| Variable | Description | Default Value |
|---|---|---|
ODOO_URL | The hostname or IP address of the Odoo server. | localhost |
ODOO_DB | The name of the Odoo database to connect to. | mydb |
ODOO_USERNAME | The username for Odoo authentication. | admin |
ODOO_PASSWORD | The password for Odoo authentication. | admin |
Sources: app/main.py:10-13, charts/odooconnectorapi/values.yaml:16-20
Configuration Logic Flow
The following diagram illustrates how environment variables flow from the system environment into the application logic to initialize the Odoo connection.
Sources: app/main.py:10-13, app/main.py:27-28
Containerized Environment (Docker)
When running via Docker Compose, the environment variables are passed from a .env file or the host shell into the container. The docker-compose.yml file maps these variables to the web service, which runs the Uvicorn server.
environment:
ODOO_URL: ${ODOO_URL}
ODOO_DB: ${ODOO_DB}
ODOO_USERNAME: ${ODOO_USERNAME}
ODOO_PASSWORD: ${ODOO_PASSWORD}
Sources: docker-compose.yml:9-13
In the dedicated Odoo infrastructure configuration (located in the odoo/ directory), environment variables are also used to configure the Odoo service dependency on the PostgreSQL database.
| Service | Variable | Value | Source |
|---|---|---|---|
| Postgres (db) | POSTGRES_DB | odoodb | odoo/docker-compose.yml:55 |
| Postgres (db) | POSTGRES_USER | odoo | odoo/docker-compose.yml:56 |
| Postgres (db) | POSTGRES_PASSWORD | odoo | odoo/docker-compose.yml:57 |
| Odoo (web) | HOST | db | odoo/docker-compose.yml:41 |
| Odoo (web) | USER | odoo | odoo/docker-compose.yml:42 |
Kubernetes and Helm Configuration
For production deployments, the configuration is managed through Helm. The values.yaml file acts as the central source of truth, which is then injected into the Kubernetes Deployment manifests.
Helm values mapping
The values defined in values.yaml are mapped to the container environment within the deployment.yaml template.
Resource Limits
The environment is also configured with resource constraints when deployed via Docker Compose in the odoo/ directory, ensuring stability:
- CPU Limit: 0.50
- Memory Limit: 512M
Sources: odoo/docker-compose.yml:8-10, odoo/docker-compose.yml:49-51
Connectivity Architecture
The environment configuration facilitates the communication between the FastAPI application and the Odoo backend. The following sequence diagram shows how the configuration parameters are utilized during a request to fetch data.
Sources: app/main.py:25-39
Summary
The OdooConnectorAPI environment configuration is designed for portability and security. By using standard environment variables, the system can be easily adjusted for local development using a .env file, or scaled in a Kubernetes cluster using Helm values. The primary focus of the configuration is maintaining the credentials and network location of the Odoo ERP instance.