apiVersion: v1
kind: Service
metadata:
  name: {{ template "tempo.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "tempo.labels" . | nindent 4 }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
  type: ClusterIP
  {{- if .Values.service.clusterIP }}
  clusterIP: {{ .Values.service.clusterIP }}
  {{ end }}
{{- else if eq .Values.service.type "LoadBalancer" }}
  type: {{ .Values.service.type }}
  {{- if .Values.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  {{- if .Values.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
    {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
  {{- end -}}
{{- else }}
  type: {{ .Values.service.type }}
  {{- if .Values.service.externalIPs }}
  externalIPs:
    {{- toYaml .Values.service.externalIPs | nindent 4 }}
  {{- end }}
{{- end }}
  ports:
  - name: tempo-prom-metrics
    port: 3100
    targetPort: 3100
  {{- if .Values.tempoQuery.enabled }}
  - name: jaeger-metrics
    port: 16687
    targetPort: 16687
  - name: tempo-query-jaeger-ui
    port: {{ .Values.tempoQuery.service.port }}
    targetPort: {{ .Values.tempoQuery.service.port }}
  {{- end }}
#  - name: tempo-jaeger-thrift-compact
#    port: 6831
#    protocol: UDP
#    targetPort: 6831
#  - name: tempo-jaeger-thrift-binary
#    port: 6832
#    protocol: UDP
#    targetPort: 6832
#  - name: tempo-jaeger-thrift-http
#    port: 14268
#    protocol: TCP
#    targetPort: 14268
#  - name: grpc-tempo-jaeger
#    port: 14250
#    protocol: TCP
#    targetPort: 14250
#  - name: tempo-zipkin
#    port: 9411
#    protocol: TCP
#    targetPort: 9411
  - name: tempo-otlp-legacy
    port: 55680
    protocol: TCP
    targetPort: 55680
  - name: tempo-otlp-http-legacy
    port: 55681
    protocol: TCP
    targetPort: 4318
  - name: grpc-tempo-otlp
    port: 4317
    protocol: TCP
    targetPort: 4317
  - name: tempo-otlp-http
    port: 4318
    protocol: TCP
    targetPort: 4318
#  - name: tempo-opencensus
#    port: 55678
#    protocol: TCP
#    targetPort: 55678
  selector:
    {{- include "tempo.selectorLabels" . | nindent 4 }}
