apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: db
  name: db
  namespace: pos
spec:
  selector:
    matchLabels:
      app: db
  serviceName: db
  replicas: 1
  template:
    metadata:
      annotations:
        appuio.ch/backupcommand: pg_dumpall
      labels:
        app: db
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: db
        image: postgres:10
        env:
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        - name: POSTGRES_DB
          value: postgres
        - name: POSTGRES_PASSWORD
          value: odoo
        - name: PGPASSWORD
          value: odoo
        - name: POSTGRES_USER
          value: odoo
        - name: PGUSER
          value: odoo
        ports:
        - containerPort: 5432
          name: postgres
        volumeMounts:
        - name: db-data
          mountPath: /var/lib/postgresql/data/pgdata
  volumeClaimTemplates:
  - metadata:
      name: db-data
      annotations:
        appuio.ch/backup: "true"
    spec:
      accessModes:
      - ReadWriteOnce
      storageClassName: local-path
      resources:
        requests:
          storage: 1Gi
