{{- if .Values.tempo.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: tempo
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  destination:
    namespace: tempo
    server: 'https://kubernetes.default.svc'
  project: aux
  syncPolicy:
    # managedNamespaceMetadata:
    #   labels:
    #     component: aux
    syncOptions:
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
    automated:
      prune: true
      selfHeal: true
  sources:
  - repoURL: 'https://grafana.github.io/helm-charts'
    targetRevision: 1.10.3
    chart: tempo
    helm:
      values: |
        tempo:
          storage:
            trace:
              backend: s3
              s3:
                bucket: tempo-traces
                endpoint: 10.255.241.30:30080
                access_key: ${S3KEY}
                secret_key: ${S3SECRET}
                forcepathstyle: true
                insecure: true
              local:
                path: /var/tempo/traces
              wal:
                path: /var/tempo/wal
          metricsGenerator:
            enabled: true
            remoteWriteUrl: "http://prom-prometheus.prometheus:9090/api/v1/write"
          extraArgs: { config.expand-env=true }
          extraEnv:
          - name: S3KEY
            valueFrom:
              secretKeyRef:
                name: tempo-s3
                key: AWS_ACCESS_KEY_ID
          - name: S3SECRET
            valueFrom:
              secretKeyRef:
                name: tempo-s3
                key: AWS_ACCESS_KEY_SECRET
        tempoQuery:
          ingress:
            enabled: true
            ingressClassName: nginx
            annotations:
              cert-manager.io/cluster-issuer: letsencrypt-staging
              nginx.ingress.kubernetes.io/ssl-redirect: "true"
              oceanbox.io/expose: internal
            path: /
            pathType: Prefix
            hosts:
              - query.tempo.adm.oceanbox.io
            tls:
             - secretName: tempo-query-tls
               hosts:
                 - query.tempo.adm.oceanbox.io
{{- end }}
