Application Demo: Odoo

Demo application logo This tutorial explains how to run Odoo on APPUiO Cloud.

If you aren’t familiar with issuing commands on a terminal session, we recommend familiarizing yourself with it before continuing this tutorial.

Requirements

To follow this guide, please make sure that you have the following tools installed:

oc

You can download the OpenShift command directly from APPUiO Cloud, selecting the help menu (marked as a question mark) and selecting the "Command line tools" entry

About the Application

Amazing employees deserve amazing software

The only platform you will ever need to help run your business: integrated apps, kept simple, and loved by millions of happy users.

Step 1: Create a Project

All the following steps are currently only working on the Exoscale APPUiO Zone because of the Application Catalog service availability.

Follow these steps to login to APPUiO Cloud on your terminal:

  1. Login to the APPUiO Cloud console:

    oc login --server=https://api.${zone}.appuio.cloud:6443

    You can find the exact URL of your chosen zone in the APPUiO Cloud Portal.

    This command displays a URL on your terminal:

    You must obtain an API token by visiting
    https://oauth-openshift.apps.${zone}.appuio.cloud/oauth/token/request
  2. Click on the link above and open it in your browser.

  3. Click "Display token" and copy the login command shown as "Log in with this token"

  4. Paste the oc login command on the terminal:

    oc login --token=sha256~_xxxxxx_xxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxx-X \
        --server=https://api.${zone}.appuio.cloud:6443
  5. Create a new project called "[YOUR_USERNAME]-application-demo"

    oc new-project "[YOUR_USERNAME]-application-demo"

Step 2: Deploy the application

To deploy the application we will use standard Kubernetes objects. Save the example YAML Kubernetes resources into a file and apply it with oc apply -f <myfile.yaml>.

  1. First, we need a database:

    Database ordering from the VSHN Application Catalog
    apiVersion: exoscale.appcat.vshn.io/v1
    kind: ExoscalePostgreSQL
    metadata:
      name: example-app
    spec:
      writeConnectionSecretToRef:
        name: postgresql-creds

    This will create a PostgreSQL DBaaS instance with default settings. See the AppCat docs for more information.

  2. Then we deploy the application:

    Application deployment with all other needed resources
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: odoo
      labels:
        app.kubernetes.io/name: demo-app
    spec:
      selector:
        matchLabels:
          app.kubernetes.io/name: demo-app
      replicas: 1
      strategy:
        type: Recreate
      template:
        metadata:
          labels:
            app.kubernetes.io/name: demo-app
        spec:
          containers:
            - name: odoo
              ## Until https://github.com/bitnami/containers/issues/17806 is solved
              ## we have to use a temporary image which is built with the proposed
              ## fix in https://github.com/bitnami/containers/pull/17885
              #image: docker.io/bitnami/odoo:latest
              image: docker.io/tobru/bitnami-odoo:dev
              imagePullPolicy: Always
              env:
                - name: ODOO_DATABASE_HOST
                  valueFrom:
                    secretKeyRef:
                      name: postgresql-creds
                      key: POSTGRESQL_HOST
                - name: ODOO_DATABASE_PORT_NUMBER
                  valueFrom:
                    secretKeyRef:
                      name: postgresql-creds
                      key: POSTGRESQL_PORT
                - name: ODOO_DATABASE_USER
                  valueFrom:
                    secretKeyRef:
                      name: postgresql-creds
                      key: POSTGRESQL_USER
                - name: ODOO_DATABASE_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: postgresql-creds
                      key: POSTGRESQL_PASSWORD
                - name: ODOO_DATABASE_NAME
                  valueFrom:
                    secretKeyRef:
                      name: postgresql-creds
                      key: POSTGRESQL_DB
                - name: ODOO_LOAD_DEMO_DATA
                  value: "yes"
                - name: ODOO_SKIP_BOOTSTRAP
                  value: "no"
                - name: ODOO_EMAIL
                  value: "user@example.com"
              ports:
                - name: web
                  containerPort: 8069
                  protocol: TCP
              resources:
                limits: {}
                requests: {}
              volumeMounts:
                - name: app-data
                  mountPath: /bitnami/odoo
                - name: db-ca
                  mountPath: /srv/db-ca
          volumes:
            - name: app-data
              persistentVolumeClaim:
                claimName: app-data
            - name: db-ca
              secret:
                secretName: postgresql-creds
                optional: false
                items:
                  - key: ca.crt
                    path: ca.crt
    ---
    apiVersion: batch/v1
    kind: Job
    metadata:
      name: create-db-postgres
    spec:
      ttlSecondsAfterFinished: 240
      template:
        spec:
          containers:
          - command:
            - sh
            - -c
            - |
              psql \
              "postgres://${ODOO_DATABASE_USER}:${ODOO_DATABASE_PASSWORD}@${ODOO_DATABASE_HOST}:${ODOO_DATABASE_PORT_NUMBER}/${ODOO_DATABASE_NAME}?sslmode=require" \
              -c 'CREATE DATABASE postgres WITH OWNER=avnadmin'
            image: docker.io/bitnami/postgresql:latest
            name: create-db-postgres
            env:
              - name: ODOO_DATABASE_HOST
                valueFrom:
                  secretKeyRef:
                    name: postgresql-creds
                    key: POSTGRESQL_HOST
              - name: ODOO_DATABASE_PORT_NUMBER
                valueFrom:
                  secretKeyRef:
                    name: postgresql-creds
                    key: POSTGRESQL_PORT
              - name: ODOO_DATABASE_USER
                valueFrom:
                  secretKeyRef:
                    name: postgresql-creds
                    key: POSTGRESQL_USER
              - name: ODOO_DATABASE_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: postgresql-creds
                    key: POSTGRESQL_PASSWORD
              - name: ODOO_DATABASE_NAME
                valueFrom:
                  secretKeyRef:
                    name: postgresql-creds
                    key: POSTGRESQL_DB
            resources:
              limits: {}
              requests: {}
          restartPolicy: OnFailure
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: example-app
      labels:
        app.kubernetes.io/name: demo-app
    spec:
      type: ClusterIP
      sessionAffinity: None
      ports:
        - name: web
          port: 443
          protocol: TCP
          targetPort: web
      selector:
        app.kubernetes.io/name: demo-app
    ---
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: app-data
      labels:
        app.kubernetes.io/name: demo-app
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: "1Gi"
    ---
    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
      name: example-app
    spec:
      port:
        targetPort: web
      to:
        kind: Service
        name: example-app
        weight: 100
      wildcardPolicy: None
      tls:
        termination: edge
        insecureEdgeTerminationPolicy: Redirect
  3. Now wait until your pod appears with the status "Running":

    oc get pods --watch
  4. Last but not least retrieve the URL of your Odoo instance:

    oc get route example-app -o jsonpath='{.spec.host}'

You can now login to your Odoo instance with the default credentials by the image:

  • Username: user@example.com

  • Password: bitnami

This example configuration isn’t meant for a production ready service.

What’s next?

For a production ready service, we recommend the following parts to be implemented and configured:

Especially for this example application:

  • Change the default username and password immediately.

  • Review the documentation of the used image to learn more about the configuration and possibilities.

  • Odoo needs a proper mail sending configuration in production, we recommend using a managed mail sending service for that, for example Mailgun.

Once you’re done evaluating this example application, cleanup again to not cause any unwanted costs:

oc delete project [YOUR_USERNAME]-application-demo