---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: dataverse
  labels:
    app.kubernetes.io/name: dataverse
    app.kubernetes.io/version: "4.16"
    app.kubernetes.io/component: appserver
    app.kubernetes.io/part-of: dataverse
    app.kubernetes.io/managed-by: kubectl
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: dataverse
      app.kubernetes.io/part-of: dataverse
      app.kubernetes.io/component: appserver
  revisionHistoryLimit: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: dataverse
        app.kubernetes.io/part-of: dataverse
        app.kubernetes.io/component: appserver
    spec:
      containers:
        - name: dataverse
          image: iqss/dataverse-k8s
          ports:
            - containerPort: 8080
          envFrom:
            - configMapRef:
                name: dataverse
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: dataverse-postgresql
                  key: username
                  optional: true
            - name: POSTGRES_DATABASE
              valueFrom:
                secretKeyRef:
                  name: dataverse-postgresql
                  key: database
                  optional: true
          volumeMounts:
            - name: files
              mountPath: /data
            - name: docroot
              mountPath: /docroot
            - name: db-secret
              mountPath: "/opt/dataverse/secrets/db"
              readOnly: true
            - name: doi-secret
              mountPath: "/opt/dataverse/secrets/doi"
              readOnly: true
          readinessProbe:
            httpGet:
              path: /robots.txt
              port: 8080
      initContainers:
        - name: volume-mount-hack
          image: giantswarm/tiny-tools
          command: ["sh", "-c", "chown -c 1000:1000 /data /docroot"]
          volumeMounts:
            - name: files
              mountPath: /data
            - name: docroot
              mountPath: /docroot
      volumes:
        - name: files
          persistentVolumeClaim:
            claimName: dataverse-files
        - name: docroot
          persistentVolumeClaim:
            claimName: dataverse-docroot
        - name: db-secret
          secret:
            secretName: dataverse-postgresql
        - name: doi-secret
          secret:
            secretName: dataverse-doi
