# Copyright (c) 2020 SIGHUP s.r.l All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: core
  labels:
    app: harbor
    component: core
spec:
  replicas: 1
  selector:
    matchLabels:
      app: harbor
      component: core
  template:
    metadata:
      labels:
        app: harbor
        component: core
    spec:
      securityContext:
        fsGroup: 10000
      containers:
        - name: core
          image: goharbor/harbor-core
          imagePullPolicy: Always
          livenessProbe:
            httpGet:
              path: api/v2.0/ping
              port: 8080
            initialDelaySeconds: 300
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: api/v2.0/ping
              port: 8080
            initialDelaySeconds: 20
            periodSeconds: 10
          resources:
            requests:
              memory: 256Mi
              cpu: 100m
          envFrom:
            - configMapRef:
                name: core
            - secretRef:
                name: core
          env:
            - name: CORE_SECRET
              valueFrom:
                secretKeyRef:
                  name: core
                  key: secret
            - name: JOBSERVICE_SECRET
              valueFrom:
                secretKeyRef:
                  name: jobservice
                  key: secret
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: config
              mountPath: /etc/core/app.conf
              subPath: app.conf
            - name: secret-key
              mountPath: /etc/core/key
              subPath: key
            - name: token-service-private-key
              mountPath: /etc/core/private_key.pem
              subPath: tls.key
            - name: psc
              mountPath: /etc/core/token
      volumes:
        - name: config
          configMap:
            name: core
            items:
              - key: app.conf
                path: app.conf
        - name: secret-key
          secret:
            secretName: core
            items:
              - key: secretKey
                path: key
        - name: token-service-private-key
          secret:
            secretName: core-root-ca
        - name: psc
          emptyDir: {}
