apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: odoo
  name: odoo
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: odoo
  template:
    metadata:
      labels:
        app: odoo
    spec:
      initContainers:
        - name: git-cloner
          image: docker.io/alpine/git
          args:
            - clone
            - --branch
            - "16.0"
            - --single-branch
            - --depth
            - "1"
            - --
            - https://git.tbrnt.ch/tobru/odoo-addons.git
            - /data
          volumeMounts:
            - mountPath: /data
              name: odoo-addons
      containers:
        - env:
            - name: HOST
              value: postgres
            - name: USER
              valueFrom:
                secretKeyRef:
                  name: credentials
                  key: POSTGRES_USER
            - name: PASSWORD
              valueFrom:
                secretKeyRef:
                  name: credentials
                  key: POSTGRES_PASSWORD
          image: docker.io/library/odoo:16
          imagePullPolicy: Always
          name: web
          ports:
            - name: http
              containerPort: 8069
          resources: {}
          livenessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 30
            periodSeconds: 30
            timeoutSeconds: 5
            successThreshold: 1
            failureThreshold: 6
          readinessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 5
            successThreshold: 1
            failureThreshold: 6
          volumeMounts:
            - mountPath: /var/lib/odoo
              name: odoo-data
            - mountPath: /mnt/extra-addons
              name: odoo-addons
            - mountPath: /etc/odoo
              name: odoo-conf
      hostname: web
      restartPolicy: Always
      volumes:
        - name: odoo-data
          persistentVolumeClaim:
            claimName: odoo-data
        - name: odoo-addons
          emptyDir: {}
        - name: odoo-conf
          secret:
            secretName: odoo-conf
