apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: odoo
  namespace: odoo
  labels:
    app: odoo
spec:
  serviceName: "odoo"
  replicas: 1
  selector:
    matchLabels:
      app: odoo
  template:
    metadata:
      labels:
        app: odoo
    spec:
      containers:
        - name: db
          image: postgres:latest
          envFrom:
            - configMapRef:
                name: postgres-configuration
          ports:
            - containerPort: 5432
          volumeMounts:
            - name: pv-data
              mountPath: /var/lib/postgresql/data
              subPath: data
        - name: odoo
          image: odoo:latest
          ports:
            - containerPort: 8069
          env:
            - name: "HOST"
              value: "localhost"
            - name: "USER"
              value: "odoo"
            - name: "PASSWORD"
              value: "odoo"
      volumes:
        - name: pv-data
          persistentVolumeClaim:
            claimName: postgres-pvc
