apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: loraserverio
  name: postgres
  labels:
    app: postgres
spec:
  serviceName: "postgres"
  replicas: 1
  selector:
    matchLabels:
      component: postgres
  template:
    metadata:
      labels:
        component: postgres
    spec:
      containers:
        - name: postgres
          image: postgres:11-alpine
          ports:
            - containerPort: 5432
              name: http
          volumeMounts:
            - name: data
              mountPath: /var/lib/postgresql
              subPath: data
            - name: init-db
              mountPath: /docker-entrypoint-initdb.d
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: postgres-data
        - name: init-db
          configMap:
            name: init-config
