This repository contains the source code and configuration files for deploying Odoo 18.0 in a High Availability (HA) setup. The deployment setup is designed to ensure Odoo's scalability, reliability, and performance i n a production environment.
- High Availability (HA) for Odoo 18.0 deployment.
- Dockerized Odoo with multi-instance setup for load balancing.
- Automated infrastructure provisioning using Terraform.
- Scalable database setup for Odoo (PostgreSQL cluster).
- Support for Odoo customizations and additional modules.
- Easy-to-use GitHub Actions workflows for CI/CD.
To deploy and work with this setup, ensure you have the following prerequisites installed configured:
- Docker (for packaging code)
- kubectl (for managing Kubernetes clusters)
- AWS ECR (for storing the Docker image)
- Kubernetes cluster (running in AWS, GCP, or any other cloud provider)
- Terraform (for managing infrastructure)
- Python 3.x (for any development or manual setups)
- AWS CLI (if you're using AWS as your cloud provider)
- GitHub account (for accessing GitHub Actions)
Additionally, ensure you have access to a cloud provider (like AWS, GCP, or Azure) for provisioning infrastructure if you're using the Terraform scripts.
-
sudo apt-get update sudo apt-get install -y docker.io sudo systemctl enable docker sudo systemctl start docker -
If you haven't already, install the AWS CLI to interact with AWS services:
# Install AWS CLI sudo apt-get install -y awscliMake sure you configure the AWS CLI with your credentials:
aws configure
-
If you're deploying the application to Kubernetes, you will need to install kubectl:
# Install kubectl sudo apt-get update sudo apt-get install -y kubectl -
For provisioning the infrastructure, install Terraform:
# Install Terraform sudo apt-get update sudo apt-get install -y wget unzip wget https://releases.hashicorp.com/terraform/1.3.7/terraform_1.3.7_linux_amd64.zip unzip terraform_1.3.7_linux_amd64.zip sudo mv terraform /usr/local/bin/
First, clone the repository to your local machine or server:
git clone https://github.com/oriafo/ha_odoo-18.0_deployment.git
cd ha_odoo-18.0_deploymentThe repository includes configurations for setting up PostgreSQL in a high-availability (HA) configuration, such as master-slave replication.
You can find the relevant configuration files under the postgresql directory.
-
Initialize and configure the PostgreSQL cluster:
Ensure your database instances (master and slave) are correctly configured and running. You can find the configuration files in the
postgresql/directory. -
Configure your Odoo instance to connect to the HA PostgreSQL cluster by modifying the odoo.conf file located in the odoo/ directory.
Example odoo.conf configuration:
[options]
db_host = db_master_ip
db_port = 5432
db_user = odoo_user
db_password = odoo_password
addons_path = addons
logfile = /var/log/odoo/odoo.logIf you're deploying Odoo with multiple application nodes, you may wish to set up a load balancer (such as Nginx or HAProxy) to balance the traffic between your Odoo instances.
Example Nginx Configuration:
upstream odoo {
server odoo-instance-1:8069;
server odoo-instance-2:8069;
}
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://odoo;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}If you're deploying on cloud infrastructure (AWS, GCP, etc.), the repository includes Terraform scripts to provision the necessary infrastructure for high availability.
-
Create remote backend infrastructure:
cd infra/backend/ terraform init terraform apply -auto-approveNote:environment can be dev, staging, production and global, as this represent different deployment environment -
Navigate to the Terraform directory:
cd infra/file-structure/<environment>
Note:environment can be dev, staging, production and global, as this represent different deployment environment -
Initialize Terraform:
Initialize Terraform with the following command:
terraform init
-
Check the resources to be provisioned:
After setting up your cloud provider credentials (e.g., AWS, GCP), check for the resources in the configuration to apply:
terraform plan -out=plan.tfplan
-
Apply the configuration:
After setting up your cloud provider credentials (e.g., AWS, GCP), apply the configuration to provision the infrastructure:
terraform apply -auto-approve
Follow the prompts to approve and provision the resources.
-
Access your deployed Odoo instance:
Once Terraform finishes provisioning the resources, it will output the IP addresses or domain names of the deployed infrastructure. Access your Odoo application via the provided URL.
Make sure the Odoo application is properly configured to work with the database, and load balancer. Modify odoo.conf according to your deployment setup.
This repository includes automated GitHub Actions workflows to streamline deployment and testing.
-
infra.yml: Automates the deployment of Odoo using Terraform and Kubernetes setup. -
destroy.yml: Automate the destruction of deployed terraform resources.
Infra Workflow is automatically triggered by pull request to the staging and main branches. You can manually trigger destroy workflow from the Actions tab in GitHub.
For example, to trigger a deployment, create a pull request to the staging and main branch:
gh pr create --base <branch to merge into> --head <branch to merge from> --title <"Title of your pull request"> --body <"Detailed description of your changes">GitHub Actions will automatically trigger the infra.yml workflow to deploy your changes.
