# grafana_charts_service-gateway.yaml
{{- if .Values.gateway.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "tempo.resourceName" (dict "ctx" . "component" "gateway") }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "tempo.labels" (dict "ctx" . "component" "gateway") | nindent 4 }}
    {{- with .Values.gateway.service.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- with .Values.gateway.service.annotations }}
  annotations:
    {{- tpl (toYaml . | nindent 4) $ }}
  {{- end }}
spec:
  type: {{ .Values.gateway.service.type }}
  {{- with .Values.gateway.service.clusterIP }}
  clusterIP: {{ . }}
  {{- end }}
  {{- if and (eq "LoadBalancer" .Values.gateway.service.type) .Values.gateway.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.gateway.service.loadBalancerIP }}
  {{- end }}
  ports:
    - name: http-metrics
      port: {{ .Values.gateway.service.port }}
      targetPort: http-metrics
      {{- if and (eq "NodePort" .Values.gateway.service.type) .Values.gateway.service.nodePort }}
      nodePort: {{ .Values.gateway.service.nodePort }}
      {{- end }}
      protocol: TCP
    {{- if .Values.traces.otlp.grpc.enabled }}
    - name: grpc-otlp
      port: {{ .Values.traces.otlp.grpc.port }}
      targetPort: grpc-otlp
      protocol: TCP
    {{- end }}
    {{ range .Values.gateway.service.additionalPorts }}
    - name: {{ .name }}
      port: {{ .port }}
      targetPort: {{ .targetPort }}
      protocol: {{ .protocol }}
    {{ end }}
  selector:
    {{- include "tempo.selectorLabels" (dict "ctx" . "component" "gateway") | nindent 4 }}
{{- end }}