apiVersion: "apps/v1"
kind: Deployment
metadata:
  namespace: postgres
  name: postgres
spec:
  replicas: 1

  selector:
    matchLabels:
      app: postgres

  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: uc4official/postgres:latest
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          envFrom:
            - configMapRef:
                name: postgres-config
          volumeMounts:
            - name: postgredb
              mountPath: /var/lib/postgresql/data
            - name: config-volume
              mountPath: /uc4
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-pv-claim
        - name: config-volume
          configMap:
            name: postgresql
            items:
              - key: "config"
                path: "postgresql.conf"