---
bases:
  - envs/common.yaml
---
releases:

################################################################################
## Report-Portal ###############################################################
################################################################################

#
# References:
#   - - https://github.com/reportportal/kubernetes/tree/develop/reportportal
#
- name: "minio"
  namespace: report-portal
  labels:
    chart: "minio"
    repo: "minio"
    component: "report-portal-third-party-resources"
    namespace: report-portal
    vendor: "minio"
    default: "true"
  chart: "bitnami/minio"
  version: "12.1.7"
  {{- if eq .Values.global.platform "openshift" }}
  hooks:
    - events: ["prepare"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-third-party-resources-scc.yaml"]
    - events: ["postuninstall"]
      showlogs: true
      command: "kubectl"
      args: ["delete", "-f", "../resources/report-portal-third-party-resources-scc.yaml"]
  {{- end }}
  wait: true
  installed: true
  values:
    - auth:
        existingSecret: reportportal-minio-creds
      persistence:
        size: 1Gi

- name: "rabbitmq"
  namespace: report-portal
  labels:
    chart: "rabbitmq"
    repo: "rabbitmq"
    component: "report-portal-third-party-resources"
    namespace: report-portal
    vendor: "rabbitmq"
    default: "true"
  chart: "bitnami/rabbitmq"
  version: "11.9.3"
  wait: true
  installed: true
  values:
    - auth:
        existingPasswordSecret: reportportal-rabbitmq-creds
        existingErlangSecret: reportportal-rabbitmq-creds
      persistence:
        size: 1Gi

- name: "elasticsearch"
  namespace: report-portal
  labels:
    chart: "elasticsearch"
    repo: "elasticsearch"
    component: "report-portal-third-party-resources"
    namespace: report-portal
    vendor: "elasticsearch"
    default: "true"
  chart: "elastic/elasticsearch"
  version: "7.17.3"
  {{- if eq .Values.global.platform "openshift" }}
  hooks:
    - events: ["prepare"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-elasticsearch-scc.yaml"]
    - events: ["postuninstall"]
      showlogs: true
      command: "kubectl"
      args: ["delete", "-f", "../resources/report-portal-elasticsearch-scc.yaml"]
  {{- end }}
  wait: true
  installed: true
  values:
    - replicas: 1

      rbac:
        create: true

      extraEnvs:
        - name: discovery.type
          value: single-node
        - name: cluster.initial_master_nodes
          value: ""

      resources:
        requests:
          cpu: "100m"
          memory: "2Gi"

      volumeClaimTemplate:
        resources:
          requests:
            storage: 3Gi

- name: "postgresql"
  namespace: report-portal
  labels:
    chart: "postgresql"
    repo: "postgresql"
    component: "report-portal-third-party-resources"
    namespace: report-portal
    vendor: "postgresql"
    default: "true"
  chart: "bitnami-archive/postgresql"
  version: "10.9.4"
  wait: true
  installed: true
  values:
    - persistence:
        size: 1Gi
      resources:
        requests:
          cpu: "100m"
      serviceAccount:
        enabled: true
      postgresqlUsername: "rpuser"
      postgresqlDatabase: "reportportal"
      existingSecret: "reportportal-postgresql-creds"
      initdbScripts:
        init_postgres.sh: |
          #!/bin/sh
          /opt/bitnami/postgresql/bin/psql -U postgres -d ${POSTGRES_DB} -c 'CREATE EXTENSION IF NOT EXISTS ltree; CREATE EXTENSION IF NOT EXISTS pgcrypto; CREATE EXTENSION IF NOT EXISTS pg_trgm;'

- name: "report-portal"
  namespace: report-portal
  labels:
    chart: "report-portal"
    repo: "report-portal"
    component: "report-portal"
    namespace: report-portal
    vendor: "report-portal"
    default: "true"
  chart: "report-portal/reportportal"
  version: "5.8.0"
  {{- if eq .Values.global.platform "openshift" }}
  hooks:
    - events: ["prepare"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-reportportal-scc.yaml"]
    - events: ["postuninstall"]
      showlogs: true
      command: "kubectl"
      args: ["delete", "-f", "../resources/report-portal-reportportal-scc.yaml"]

    - events: ["prepare"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-config-cm.yaml"]
    - events: ["postuninstall"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-config-cm.yaml"]

    - events: ["prepare"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-deployment.yaml"]
    - events: ["postuninstall"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-deployment.yaml"]

    - events: ["prepare"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-service.yaml"]
    - events: ["postuninstall"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-service.yaml"]

    - events: ["prepare"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-route.yaml"]
    - events: ["postuninstall"]
      showlogs: true
      command: "kubectl"
      args: ["apply", "-f", "../resources/report-portal-gateway/gateway-route.yaml"]
  {{- end }}
  wait: true
  installed: true
  values:
    - serviceindex:
        resources:
          requests:
            cpu: 50m
      uat:
        resources:
          requests:
            cpu: 50m
      serviceui:
        resources:
          requests:
            cpu: 50m
        serviceAccountName: "reportportal"
        securityContext:
          runAsUser: 0
      serviceapi:
        resources:
          requests:
            cpu: 50m
      serviceanalyzer:
        resources:
          requests:
            cpu: 50m
      serviceanalyzertrain:
        resources:
          requests:
            cpu: 50m

      rabbitmq:
        SecretName: "reportportal-rabbitmq-creds"
        endpoint:
          address: rabbitmq.report-portal.svc.cluster.local
          user: user
          apiuser: user

      postgresql:
        SecretName: "reportportal-postgresql-creds"
        endpoint:
          address: postgresql.report-portal.svc.cluster.local

      elasticsearch:
        endpoint: http://elasticsearch-master.report-portal.svc.cluster.local:9200

      minio:
        secretName: "reportportal-minio-creds"
        endpoint: http://minio.report-portal.svc.cluster.local:9000
        endpointshort: http://minio.report-portal.svc.cluster.local:9000
        accesskeyName: "root-user"
        secretkeyName: "root-password"

      ingress:
        # IF YOU HAVE SOME DOMAIN NAME SET INGRESS.USEDOMAINNAME to true
        usedomainname: true
        hosts:
          - report-portal-{{ .Values.global.edpName }}.{{ .Values.global.dnsWildCard }}
