apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: postgres-db
  name: postgres-db
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres-db
  template:
    metadata:
      labels:
        app: postgres-db
    spec:
      containers:
        - name: postgres-db
          image: target/consensource-db:postgres-12.4
          imagePullPolicy: Always
          ports:
            - containerPort: 5432
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-db
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: postgres
                  key: CONSENSOURCEDB_USER
            - name: POSTGRES_DB
              valueFrom:
                secretKeyRef:
                  name: postgres
                  key: CONSENSOURCEDB_NAME
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres
                  key: CONSENSOURCEDB_PASSWORD
      volumes:
        - name: postgres-db
          persistentVolumeClaim:
            claimName: db-data-pvc