---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  labels:
    app: postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      # ===================================================================================================== containers
      containers:
        - name: postgres
          image: postgres:12-alpine
          ports:
            - containerPort: 5432
          volumeMounts:
            - name: postgres-storage
              mountPath: /var/lib/postgresql/data
              subPath: postgres
          env:
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres
                  key: PG_PASSWORD
      # ======================================================================================================== volumes
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: postgres
