apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-deployment
  labels:
    component: database
spec:
  replicas: 1
  selector:
    matchLabels:
      component: database
  template:
    metadata:
      labels:
        component: database
    spec:
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: postgres-pvc
      containers:
        - name: postgres
          image: postgres:11.7-alpine
          env:
            - name: POSTGRES_USER
              value: postgres
            - name: POSTGRES_DB
              value: militerm_prod
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: env
                  key: POSTGRES_PASSWORD
          ports:
            - containerPort: 5432
          volumeMounts:
            - name: postgres-storage
              mountPath: /var/lib/postgresql/data
              subPath: postgres
