odoo in k8s: Odoo pod running then crashing

12/21/2021

I try to deploy Odoo in k8s ;

I have use the below Yaml files for odoo/postgres/services. the Odoo pod is always crashing . the logs result :

could not translate host name "db" to address: Temporary failure in name resolution

apiVersion: apps/v1
kind: Deployment
metadata:
  name: odoo3
spec:
  replicas: 1
  selector:
    matchLabels:
      app: odoo3
  template:
    metadata:
      labels:
        app: odoo3
    spec:
      containers:
      - name: odoo3
        image: odoo
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        env:
        - name: POSTGRES_DB
          value: "postgres"
        - name: POSTGRES_PASSWORD
          value: "postgres"
        - name: POSTGRES_USER
          value: "postgres"
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: odoo3
  labels:
    app: odoo3
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: odoo3
-- SEGNI SAIF
kubernetes
odoo
postgresql

1 Answer

12/22/2021

You need to specify the environment variable HOST

 env:
        - name: POSTGRES_DB
          value: "postgres"
        - name: POSTGRES_PASSWORD
          value: "postgres"
        - name: POSTGRES_USER
          value: "postgres"
        - name: HOST
          value: "your-postgres-service-name"

Your your-postgres-service-name should point to your postgres database container or server.

-- HERAwais
Source: StackOverflow