apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgres
  namespace: airflow
spec:
  selector:
    matchLabels:
      app: postgres
  serviceName: airflow
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: postgres:10-alpine
          ports:
            - containerPort: 5432
          env:
            - name: PGDATA
              value: /var/lib/postgresql/data/pgdata
          envFrom:
            - secretRef:
                name: postgres
          volumeMounts:
            - name: postgres
              mountPath: /var/lib/postgresql/data
  volumeClaimTemplates:
    - metadata:
        name: postgres
        namespace: airflow
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi