apiVersion: apps/v1
kind: Deployment
metadata:
  name: db
  namespace: production
spec:
  replicas: 1
  selector:
    matchLabels:
      app: db
  template:
    metadata:
      labels:
        app: db
    spec:
      containers:
        - name: db
          image: postgres:10.3
          env:
            - name: POSTGRES_DB
              valueFrom:
                configMapKeyRef:
                  name: db
                  key: POSTGRES_DB
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: node-kit
                  key: DB_USERNAME
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: node-kit
                  key: DB_PASSWORD
          resources:
            limits:
              memory: "128Mi"
              cpu: "500m"
          ports:
            - containerPort: 5432
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-pv-claim
      volumes:
        - name: postgres-pv-claim
          persistentVolumeClaim:
            claimName: postgres-pv-claim
