---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  namespace: fibo
  labels:
    component: postgres
    tier: data
spec:
  replicas: 1
  selector:
    matchLabels:
      component: postgres
  template:
    metadata:
      labels:
        component: postgres
        tier: data
    spec:
      containers:
        - name: postgres
          image: postgres
          env:
            - name: PGPASSWORD
              valueFrom:
                secretKeyRef:
                  name: pg-password
                  key: password
          ports:
            - containerPort: 5432
          volumeMounts:
            - name: postgres-volume
              mountPath: /var/lib/postgresql/data
              subPath: postgres
      volumes:
        - name: postgres-volume
          persistentVolumeClaim:
            claimName: database
