---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: db-postgres
  labels:
    app: db-postgres
spec:
  selector:
    matchLabels:
      app: db-postgres
  replicas: 1
  template:
    metadata:
      labels:
        app: db-postgres
    spec:
      containers:
        - name: db-postgres
          env:
            - name: POSTGRES_DB
              value: postgres_db
            - name: POSTGRES_PASSWORD
              value: password
            - name: POSTGRES_USER
              value: postgres
          image: postgres:latest
          ports:
            - containerPort: 5432
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: db-postgres-storage
      restartPolicy: Always
      volumes:
        - name: db-postgres-storage
          persistentVolumeClaim:
            claimName: db-postgres-pv-claim
