Odoo on Kubernetes

Easy Odoo installation in a Kubernetes Cluster with the Glasskube Kubernetes Operator.

Odoo is an open-source ERP ("Enterprise Resource Planning") system that provides numerous functions through the use of apps. For example, there are extensions for Customer Relationship Management (CRM), billing systems, employee management, time tracking systems, and many other apps.

Odoo was written in the Python programming language and is based on the following components:

  1. Backend, CLI, and app components written in Python: github.com/odoo/odoo
  2. JavaScript frontend framework for creating views: Frontend Documentation
  3. PostgreSQL as a relational database
  4. An optional load balancer can be placed in front of the Odoo instance.

Odoo Docker Images for Kubernetes

Odoo regularly releases new Docker images (github.com/odoo/docker) and publishes them on Docker Hub. These images make it easy to install and try out Odoo quickly. However, for production use, some adjustments and configuration settings are required:

  • Configuration of volumes for persisting files
  • Immutable image tags to ensure reproducible deployments
  • Intelligent regeneration of asset bundles

Odoo Docker Persisted Volumes

In addition to the database, Odoo also stores data in the directory /var/lib/odoo/filestore of the local file system. This mainly includes files uploaded by users. The persistence of files in the /var/lib/odoo directory can be achieved through the use of volumes.

Glasskube Odoo Docker Images with Immutable Tags

Attention In the official Docker images, the major version tag (e.g., 16.0) is overwritten with each release of a minor version. Therefore, a change to the image can only be identified by the SHA256 hash.

This leads to several problems:

  1. Deployments are not reproducible, as the image can change unexpectedly when the tag remains the same.
  2. Necessary security updates cannot be identified and installed.
  3. The Odoo asset bundles cannot be efficiently renewed.

In order to solve these problems, Glasskube extends the official Odoo Docker image and publishes this new image using immutable tags.

The Dockerfile of Glasskube Odoo images can be found here: github.com/glasskube/images/odoo The Docker images are published on Docker Hub: hub.docker.com/r/glasskube/odoo

Odoo Caches - Regenerating Assets

Odoo generates asset bundles and images based on the Odoo version included in the Docker image, stores them in the /var/lib/odoo folder, and references these assets in the ir_attachment database table. These asset bundles ( mainly JavaScript bundles) differ depending on the Odoo version for which they were built. If the Odoo version changes but the persisted asset bundles are not regenerated, an incompatibility arises between the delivered bundles and the Odoo version.

This leads to the user often seeing only a blank page after an Odoo upgrade. The following error message can be observed in the browser's JavaScript console:

UncaughtPromiseError > TypeError
Uncaught Promise > parent is undefined
TypeError: parent is undefined
removeLine@odo....

In a blog entry by Holden Rehg different variants are described to regenerate the assets.

In the Glasskube Docker image the assets are regenerated directly by deleting the database entries on the first reload if the Odoo version has changed. Among other things, the Shell script run.sh executes the following SQL command:

DELETE
FROM ir_attachment
WHERE res_model = 'ir.ui.view'
  AND name LIKE '%assets_%';

To prevent this, the assets are intelligently regenerated in the Glasskube Odoo Docker image.

Odoo Kubernetes Operator

The question now arises as to how the Glasskube Odoo Docker images can be easily deployed in a Kubernetes cluster. The Glasskube Kubernetes Operator takes care of this task. It not only individualizes the initial installation to the customer's cloud infrastructure, but also solves the above-mentioned problems of the cached incompatible Docker images and takes over the operation of the database, its backups, and the update management. Odoo updates are initiated automatically in the course of an operator update.

Odoo Kubernetes Installation

If a Kubernetes cluster already exists and kubectl is installed, the Git repository github.com/glasskube/operator must be cloned for the installation of Odoo.

git clone git@github.com:glasskube/operator.git

The deploy.sh script installs the required dependencies and custom resource definitions.

# Cluster-wide deployment of version X.Y.Z (or latest)
# of the Glasskube operator 
deploy/deploy.sh -v latest

Once the operator installation is complete, Odoo can be installed. For this purpose, only the following custom resource must be created in the cluster:

Odoo.yaml

apiVersion: "glasskube.eu/v1alpha1"
kind: Odoo
metadata:
  name: odoo
  namespace: odoo
spec:
  host: odoo.hostname.tld # hostname
  demoEnabled: true # Whether Odoo should be initially populated with demo data.
kubectl apply -f Odoo.yaml

This completes the installation. Updates to the Kubernetes operator will automatically update Odoo.

Important A DNS entry must be set on the 'LoadBalancer' or the ingress host. SSL certificates are automatically generated by the LoadBalancer or cert-manager if a ClusterIssuer is configured.

Odoo Demo Data

In the Kubernetes custom resource definition, it can be specified whether Odoo should be initially populated with demo data. For demonstrations and a first trial it is useful to set this parameter to true, but for production use this is not recommended. for productive use, however, this is not recommended.

Caution After the initial installation a change of this parameter has no influence anymore. Existing Odoo demo data will not be deleted.

Odoo backups

The Glasskube Kubernetes operator for Odoo automatically backs up the PostgreSQL database in a MinIO bucket in the glasskube-system namespace.

Odoo Runbot for developers

Odoo has developed a Runbot that automates Odoo instances for Git Branches. for Git Branches. This tool is especially useful when using Enterprise or Custom add-ons, as it can be used to merge the entire Odoo source code is merged with the add-ons. An OCA (Odoo Community Association) member has created a Runbot like version for the automated provisioning of Odoo instances in a Kubernetes cluster. created: Runboat

Conclusion

The official Odoo Docker image is not directly suitable for production use, as this does not have immutable tags and the persistence of the asset bundles leads to version update problems. With the help of the Glasskube Odoo Docker images and the Glasskube Kubernetes operator, Odoo can be installed in a Kubernetes cluster in just a few steps.

Glasskube Operator on GitHub

Our solutions for reliable
and scalable infrastructure.

Easily and scale your IT infrastructure while deploying applications quickly and securely with our cloud native technology solutions.

But it does not have to be like this

Now full data control is one click away