# This is a singleton postgres pod with a Persistent Volume Claim to an
# NFS backed volume. See nfs-volume.yaml and nfs-volume-claim.yaml
# It will be exposed as a service to the runcible namespace in mypostgres-service.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: mypostgres
  namespace: runcible
  labels:
    app: mypostgres
spec:
  # Since this is a singleton
  replicas: 1
  selector:
    matchLabels:
      app: mypostgres
  template:
    metadata:
      labels:
        app: mypostgres
    spec:
      containers:
        - name: database
          image: postgres:12-alpine
          # resources:
          #   requests:
          #     cpu: 2
          #     memory: 2Gi
          env:
            # Convert this over to use secrets instead
            - name: POSTGRES_PASSWORD
              # Don't commit your actual password
              value: example
            - name: POSTGRES_USER
              value: toor
            - name: POSTGRES_DB
              value: testdb
            # Could consider relocating the pgdata dir
            # - name: PGDATA
            #   value: /var/lib/postgresql/data
          livenessProbe:
            tcpSocket:
              port: 5432
            initialDelaySeconds: 180
            periodSeconds: 10
          ports:
            - containerPort: 5432
          volumeMounts:
            - name: postgres-data
              mountPath: /var/lib/postgresql/data
      volumes:
        - name: postgres-data
          persistentVolumeClaim:
            # The name of our pvc
            claimName: postgres-nfs
