apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  labels:
    app: postgres
    tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
      tier: backend
  template:
    metadata:
      labels:
        app: postgres
        tier: backend
    # This part here would be where the pod begins.
    spec:
      containers:
      - image: postgres:10.5-alpine
        name: postgres
        resources:
          requests:
            memory: "1G"
        env:
          # Update to using secrets once my skill level improves some.
        - name: POSTGRES_PASSWORD
          value: collector
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata          
        ports:
        - containerPort: 5432
          name: postgres
        volumeMounts:
        - name: postgres-persistent-storage
          mountPath: /var/lib/postgresql/data
      volumes:
      - name: postgres-persistent-storage
        persistentVolumeClaim:
          claimName: postgres-volumeclaim
      # This doesn't seem to work. It should let me force pod creation on nodes that
      # have the label `workload=database`.
      #nodeSelector:
      #  workload: database
