---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  namespace: '{{ .Values.POSTGRES_NS }}'
spec:
  replicas: 1
  selector:
    matchLabels:
        app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: my-db
          #image: postgres:latest
          image: postgres:alpine
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
              name: http-db
          volumeMounts:
            - mountPath: "/var/lib/postgresql"
              name: my-do-volume
          envFrom:
            - configMapRef:
                name: 'postgres-config'
      initContainers:
        - name: pgsql-data-permission-fix
          image: busybox
          command: ["/bin/chmod","-R","777", "/data"]
          volumeMounts:
            - name: my-do-volume
              mountPath: /data
      volumes:
        - name: my-do-volume
          persistentVolumeClaim:
             claimName: postgres-pvc
