apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}-postgres
  labels:
    app: {{ .Release.Name }}-postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ .Release.Name }}-postgres
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}-postgres
    spec:
      containers:
        - name: postgres
          image: {{ .Values.postgres.image }}
          ports:
            - containerPort: {{ .Values.postgres.port }}
          env:
            - name: POSTGRES_USER
              value: {{ .Values.postgres.env.POSTGRES_USER }}
            - name: POSTGRES_PASSWORD
              value: {{ .Values.postgres.env.POSTGRES_PASSWORD }}
            - name: POSTGRES_DB
              value: {{ .Values.postgres.env.POSTGRES_DB }}
          volumeMounts:
            - name: postgres-storage
              mountPath: /var/lib/postgresql/data
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: {{ .Release.Name }}-postgres-pvc
