apiVersion: apps/v1
kind: Deployment
metadata:
  name: db
  namespace: instavote
spec:
  replicas: 1
  selector:
    matchLabels:
      tier: back
      app: postgres
  minReadySeconds: 10
  template:
    metadata:
      labels:
        app: postgres
        role: db
        tier: back
        version: latest
    spec:
      containers:
      - image: postgres:latest
        imagePullPolicy: Always
        name: db
        # env:
        #   - name: POSTGRES_USER
        #     valueFrom:
        #       secretKeyRef:
        #         name: db
        #         key: POSTGRES_USER
        #   - name: POSTGRES_PASSWORD
        #     valueFrom:
        #       secretKeyRef:
        #         name: db
        #         key: POSTGRES_PASSWORD
        ports:
          - containerPort: 5432
            protocol: TCP
        volumeMounts:
          - name: pg-data-vol
            mountPath: /var/lib/postgresql/data
      volumes:
        - name: pg-data-vol
          persistentVolumeClaim:
            claimName: pg-data-pvc