apiVersion: apps/v1
kind: Deployment
metadata:
  name: catalog-manager
  namespace: TARGET_K8S_NAMESPACE
  labels:
    app: catalog-manager
spec:
  replicas: 1
  selector:
    matchLabels:
      app: catalog-manager
  template:
    metadata:
      labels:
        app: catalog-manager
    spec:
      priorityClassName: napptive-high-priority
      containers:
      - name: catalog-manager
        image: TARGET_DOCKER_REGISTRY/catalog-manager:VERSION
        imagePullPolicy: Always
        env:
          - name: AUTH_HEADER
            valueFrom:
              configMapKeyRef:
                name: jwt-config
                key: header
          - name: PROJECT_ID
            valueFrom:
              secretKeyRef:
                name: analytics-secret
                key: project_id
          - name: AUTH_SECRET
            valueFrom:
              secretKeyRef:
                name: jwt-secret
                key: secret
        envFrom:
          - configMapRef:
              name: catalog-manager-team
        args:
          - "run"
          - "--elasticAddress=http://elastic.TARGET_K8S_NAMESPACE:9200"
          - "--repositoryPath=/napptive/repository/"
          - "--adminAPIEnabled"
          - "--authEnabled"
          - "--authHeader=$(AUTH_HEADER)"
          - "--authSecret=$(AUTH_SECRET)"
          - "--teamPrivileges"
          - "--teamUsers=$(TEAM_PRIVILEGED_USERS)"
          - "--teamRepositories=$(TEAM_REPOSITORIES)"
          - "--analyticsEnabled=true"
          - "--analyticsProjectID=$(PROJECT_ID)"
          - "--launchSecureService"
        volumeMounts:
          - name: repository-path
            mountPath: "/napptive/repository"
          - name: analytics
            mountPath: "/analytics"
            readOnly: true
          - name: certificates
            mountPath: /certs
      volumes:
        #mount an pvc
      - name: repository-path
        persistentVolumeClaim:
          claimName: catalog-manager-pv-claim
      - name: analytics
        secret:
          secretName: analytics-secret
      - name: certificates
        secret:
          # The secret is generated by cert-manager upon successfully issuing of the certificate.
          secretName: catalog-manager-grpc-tls
