apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgres
  namespace: default
spec:
  selector:
    matchLabels:
      app: postgres
  replicas: 2
  serviceName: roundrobin-postgres
  template:
    metadata:
      labels:
        app: postgres
      namespace: default
    spec:
      containers:
      - name: postgres
        image: arm32v7/postgres:11.8
        imagePullPolicy: Always
        ports:
          - containerPort: 5432
        envFrom:
          - configMapRef:
              name: postgres-config
        env:
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        volumeMounts:
        - name: datadir
          mountPath: /var/lib/postgresql/data
  volumeClaimTemplates:
  - metadata:
      name: datadir
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: slow
      resources:
        requests:
          storage: 5Gi
