apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-deployment
  namespace: instabug
  labels:
   tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      volumes:
      - name: postgres-pv-storage
        persistentVolumeClaim:
          claimName: postgres-pvc
      containers:
      - name: postgres
        image: postgres:12.1
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5432
        env:
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: postgres-secret
              key: password
        - name: POSTGRES_USER
          valueFrom:
            configMapKeyRef:
              name: postgres-configmap
              key: POSTGRES_USER
        - name: PGDATA
          valueFrom:
            configMapKeyRef:
              name: postgres-configmap
              key: PGDATA
        volumeMounts:
        - mountPath: /var/lib/postgresql/data
          name: postgres-pv-storage
        resources:
          requests:
            memory: "128Mi"
            cpu: "250m"
          limits:
            memory: "256Mi"
            cpu: "500m"

