apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgresql-db
  namespace: project-namespace
spec:
  serviceName: postgresql-db-svc
  selector:
    matchLabels:
      app: postgresql-db
  replicas: 1
  template:
    metadata:
      labels:
        app: postgresql-db
    spec:
      containers:
        - name: postgresql-db
          image: postgres:13.4
          ports:
            - containerPort: 5432
          volumeMounts:
            - name: postgresql-db-disk
              mountPath: /data
          envFrom:
            - secretRef:
                name: db-password
            - configMapRef:
                name: postgres-db-config
  volumeClaimTemplates:
    - metadata:
        name: postgresql-db-disk
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
