---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  labels:
    app: war-bot
spec:
  selector:
    matchLabels:
      app: war-bot
      tier: pg
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: war-bot
        tier: pg
    spec:
      containers:
      - image: postgres:9.4-alpine
        imagePullPolicy: Always
        name: postgres
        env:
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: env
              key: POSTGRES_PASSWORD
        ports:
        - containerPort: 5432
          name: postgres
        volumeMounts:
        - name: pg-pv
          mountPath: /var/lib/postgresql/data
        resources:
          requests:
            cpu: 5m
            memory: 64Mi
          limits:
            cpu: 100m
            memory: 128Mi
      volumes:
      - name: pg-pv
        persistentVolumeClaim:
          claimName: pg-pvc
