apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: retraced-postgres
  namespace: '{{repl Namespace}}'
spec:
  selector:
    matchLabels:
      app: postgres
  serviceName: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:10.4
        env:
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        - name: POSTGRES_USER
          value: retraced
        - name: POSTGRES_PASSWORD
          value: password
        - name: POSTGRES_DB
          value: retraced
        imagePullPolicy: IfNotPresent
        livenessProbe:
          exec:
            command:
            - /bin/sh
            - -i
            - -c
            - pg_isready -h 127.0.0.1 -p 5432
          failureThreshold: 3
          initialDelaySeconds: 30
          timeoutSeconds: 5
        ports:
        - containerPort: 5432
          name: postgres
        readinessProbe:
          exec:
            command:
            - /bin/sh
            - -i
            - -c
            - pg_isready -h 127.0.0.1 -p 5432
          initialDelaySeconds: 5
          periodSeconds: 10
          timeoutSeconds: 1
        volumeMounts:
        - mountPath: /var/lib/postgresql/data
          name: retraced-datadir
      volumes:
      - name: retraced-datadir
        persistentVolumeClaim:
          claimName: retraced-datadir
  volumeClaimTemplates:
  - metadata:
      name: retraced-datadir
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi