apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.deployments.pgName }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ .Values.deployments.pgName }}
  template:
    metadata:
      labels:
        app: {{ .Values.deployments.pgName }}
    spec:
      containers:
        - name: {{ .Values.deployments.pgName }}
          image: {{ .Values.deployments.pgImage }}:{{ .Values.deployments.pgTag }}
          imagePullPolicy: {{ .Values.deployments.imagePullPolicy }}
          ports:
            - containerPort: {{ .Values.deployments.pgPort }}
          env:
            - name: POSTGRES_DB
              value: {{ .Values.deployments.pgDBName }}
            - name: POSTGRES_USER
              value: {{ .Values.deployments.pgDBUser }}
            - name: POSTGRES_PASSWORD
              value: {{ .Values.deployments.pgDBPassword }}
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgredb
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-pv-claim