# grafana_charts_ingress-query-frontend.yaml
{{- if and .Values.queryFrontend.query.enabled .Values.queryFrontend.ingress.enabled -}}
{{ $dict := dict "ctx" . "component" "query-frontend"  }}
{{- $ingressApiIsStable := eq (include "tempo.ingress.isStable" .) "true" -}}
{{- $ingressSupportsIngressClassName := eq (include "tempo.ingress.supportsIngressClassName" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "tempo.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "tempo.ingress.apiVersion" . }}
kind: Ingress
metadata:
  name: {{ include "tempo.resourceName" $dict }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "tempo.labels" $dict | nindent 4 }}
  {{- with .Values.queryFrontend.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- if and $ingressSupportsIngressClassName .Values.queryFrontend.ingress.ingressClassName }}
  ingressClassName: {{ .Values.queryFrontend.ingress.ingressClassName }}
  {{- end -}}
  {{- if .Values.queryFrontend.ingress.tls }}
  tls:
    {{- range .Values.queryFrontend.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      {{- with .secretName }}
      secretName: {{ . }}
      {{- end }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.queryFrontend.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
          {{- range .paths }}
          - path: {{ .path }}
            {{- if $ingressSupportsPathType }}
            pathType: {{ .pathType }}
            {{- end }}
            backend:
              {{- if $ingressApiIsStable }}
              service:
                name: {{ include "tempo.resourceName" $dict }}
                port:
                  number: {{ $.Values.queryFrontend.service.port }}
              {{- else }}
              serviceName: {{ include "tempo.resourceName" $dict }}
              servicePort: {{ $.Values.queryFrontend.service.port }}
              {{- end }}
          {{- end }}
    {{- end }}
{{- end }}