apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:12.7
        imagePullPolicy: "IfNotPresent"
        ports:
        - containerPort: 5432
        env:
          # TODO: Replace this with variables taken from hashicorp vault for rotating DB keys
          - name: POSTGRES_DB
            valueFrom:
              secretKeyRef:
                name: postgres-secrets
                key: POSTGRES_DB
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: postgres-secrets
                key: POSTGRES_PASSWORD
          - name: POSTGRES_USER
            valueFrom:
              secretKeyRef:
                name: postgres-secrets
                key: POSTGRES_USER
      volumes:
        - name: postgresdb
          persistentVolumeClaim:
            claimName: postgres-pvc
