apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: pg-monitor-timescaledb
  name: pg-monitor-timescaledb
spec:
  replicas: 1
  progressDeadlineSeconds: 600
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: pg-monitor-timescaledb
  template:
    metadata:
      labels:
        app: pg-monitor-timescaledb
      name: pg-monitor-timescaledb
    spec:
      containers:
      - image: timescale/timescaledb:2.0.0-rc2-pg12
        env:
          - name: PGDATA
            value: /pgdata_local/11
          - name: POSTGRES_INITDB_ARGS
            value: --data-checksums --encoding=UTF8 --locale=en_US --auth-host='md5'
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: pg-monitor-timescaledb-pg-pass
                key: password
#                value: pgpass
        imagePullPolicy: Always
        name: pg-monitor-timescaledb
        ports:
        - containerPort: 5432
          protocol: TCP
        volumeMounts:
        - name: podinfo
          mountPath: /etc/podinfo
        - name: netapp
          mountPath: /pgdata_local
#        resources:
#          requests:
#            memory: "8G"
#            cpu: 4
#          limits:
#            memory: "8G"
#            cpu: 4
      - image: lloydalbin/pg_ldap_sync:10-alpine
        env:
          - name: PGHOST
            value: pg-monitor-timescaledb
          - name: PGUSER
            value: postgres
          - name: PGPASSWORD
            valueFrom:
              secretKeyRef:
                name: pg-monitor-timescaledb-pg-pass
                key: password
#                value: pgpass
        command: ["/bin/bash"]
        args: ["-c", "while true; do sleep 5;done"]
        name: pg-ldap-sync
        resources: {}
        volumeMounts:
        - name: podinfo
          mountPath: /etc/podinfo
        - name: netapp
          mountPath: /pgdata_local
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      volumes:
# https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/          
      - name: podinfo
        downwardAPI:
          items:
            - path: "labels"
              fieldRef:
                fieldPath: metadata.labels
            - path: "annotations"
              fieldRef:
                fieldPath: metadata.annotations
      - name: netapp
        emptyDir: {}
#        persistentVolumeClaim:
#          claimName: pg-monitor-timescaledb
