apiVersion: apps/v1
kind: Deployment
metadata:
  name: pearljam-db
spec:
  selector:
    matchLabels:
      app: pearljam-db
  template:
    metadata:
      labels:
        app: pearljam-db
    spec:
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: postgres-pv-claim
      containers:
        - image: postgres
          name: postgres
          env:
            - name: PGDATA
              value: /var/lib/postgresql/data/db-files/
            - name: POSTGRES_USER
              valueFrom:
                configMapKeyRef:
                  name: postgres-config
                  key: postgres_user
            - name: POSTGRES_PASSWORD
              valueFrom:
                configMapKeyRef:
                  name: postgres-config
                  key: postgres_password
          ports:
            - containerPort: 5432
              name: postgres
          volumeMounts:
            - name: postgres-storage
              mountPath: /var/lib/postgresql/data
