apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: btt-postgres
spec:
  selector:
    matchLabels:
      app: postgres
  serviceName: "postgres"
  replicas: 1
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: btt-postgres
        image: postgres:13.3
        envFrom:
          - configMapRef:
              name: postgres-config
          - secretRef:
              name: postgres-login-secret
        ports:
        - containerPort: 5432
          name: postgres
        volumeMounts:
        - name: postgresdb
          mountPath: /var/lib/postgresql/data
          subPath: postgres
  volumeClaimTemplates:
  - metadata:
      name: postgresdb
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: do-block-storage
      resources:
        requests:
          storage: 5Gi