Cookies disclaimer

I agree Our site saves small pieces of text information (cookies) on your device in order to deliver better content and for statistical purposes. You can disable the usage of cookies by changing the settings of your browser. By browsing our website without changing the browser settings you grant us permission to store that information on your device.

Creation of odoo postgres with LoadBalancer





Don't forget if you need help putting your application in production, or you want it to do for you ? Open a ticket !

We will create an application Odoo 9 or 10 with a database of Postgres and persistent storage.

Each application will have its own deployment in order to be able to resize the "Front".

1) creation of the environment:

We will call odoo-postgres, and I would use the template "small" for the demonstration.

2) creation of storage facilities:

we are going to create 1 storage for postgres (10GB) . We will take care to note the uuid of the service to be able to map our storage with our application.

3) creation of our deployment of Postgres in our namespace:

 

{
	"name": "postgres",
	"spec": {
		"template": {
			"spec": {
				"containers": [{
					"name": "postgres",
					"image": "sameersbn/postgresql:9.5-2",
					"volumeMounts": [{
						"mountPath": "/var/lib/postgresql",
						"name": "postgres-persistent-storage"
					}],
					"env": [{
						"name": "DB_USER",
						"value": "odoo"
					}, {
						"name": "DB_PASS",
						"value": "odoo"
					}],
					"ports": [{
						"containerPort": 5432,
						"name": "db"
					}],
					"resources": {
						"limits": {
							"memory": "1Gi",
							"cpu": "1"
						}
					}
				}],
				"volumes": [{
					"image": "UUID_DU_STOCKAGE",
					"name": "postgres-persistent-storage"
				}]
			}
		},
		"replicas": 1
	}
}

 

4) Create a loadBalancer for postgres :

We create a load balancer to expose postgres in our application, Odoo, to do this you go to Menu >> Container Cloud >> Loadbalancer.

It selects the name of our deployment ( for me postgres ), the Cname is not necessary because we do not want to expose postgres on the internet, as the name we put "postgres" and the port to 5432 ( standart port for postgresql ), the public field is not checked.

5) creation of our deployment in Odoo:

If you want to odoo 9 replace the image "hebus/odoo:10.0" by "odoo"

{
      "name": "odoo", 
      "spec": {
            "template": {
                  "spec": {
                        "containers": [
                              {
                                    "name": "odoo", 
                                    "image": "hebus/odoo:10.0", 
                                    "volumeMounts": [], 
                                    "env": [
                                          {
                                                "name": "PGHOST", 
                                                "value": "postgres"
                                          },
                                          {
                                                "name": "PGPORT", 
                                                "value": "5432"
                                          },
                                          {
                                                "name": "PGPASSWORD", 
                                                "value": "odoo"
                                          },
                                          {
                                                "name": "PGUSER", 
                                                "value": "odoo"
                                          }
                                    ], 
                                    "imagePullPolicy": "Always", 
                                    "ports": [
                                          {
                                                "containerPort": 8069, 
                                                "name": "odoo"
                                          }
                                    ], 
                                    "resources": {
                                          "limits": {
                                                "cpu": "1", 
                                                "memory": "1Gi"
                                          }
                                    }
                              }
                        ], 
                        "volumes": []
                  }
            }, 
            "replicas": 1
      }
}

 

6) Now we will expose our application to Odoo so that it is accessible from the browser.

To do this, we are going in the Menu >> Container Cloud >> Loadbalancer and we fill in as follows ( please note that only the cnames .apps.hebus.io are available, if you wish to put your domain you will need to create a Cname at your registrar pointing to lb.hebus.io )