apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  generation: 1
  labels:
    app: dspace-postgresql
    chart: postgresql-0.8.1
    heritage: Tiller
    release: dspace
  name: dspace-postgresql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dspace-postgresql
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: dspace-postgresql
    spec:
      containers:
      - env:
        - name: POSTGRES_USER
          value: dspace
        - name: PGUSER
          value: dspace
        - name: POSTGRES_DB
        - name: POSTGRES_INITDB_ARGS
        - name: dspaceuser
          value: dbuser
        - name: dspacepassword
          valueFrom:
            secretKeyRef:
              key: dspace.password
              name: dspace-secrets
        - name: dspacedbname
          value: dbname
        - name: dspaceutilsdbname
          value: dbnamespace
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              key: postgres-password
              name: dspace-postgresql
        - name: POD_IP
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: status.podIP
        image: gitlab.scientificnet.org:4567/commul/dspace/postgres:0.3
        imagePullPolicy: IfNotPresent
        livenessProbe:
          exec:
            command:
            - sh
            - -c
            - exec pg_isready --host $POD_IP
          failureThreshold: 6
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        name: dspace-postgresql
        ports:
        - containerPort: 5432
          name: postgresql
          protocol: TCP
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - exec pg_isready --host $POD_IP
          failureThreshold: 3
          initialDelaySeconds: 5
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 3
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /var/lib/postgresql/data/pgdata
          name: data
          subPath: postgresql-db
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: gitlab-scientificnet-org-registry
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: dspace-postgresql
