{{- if .Values.collector.enabled -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "jaeger.collector.name" . }}
  labels:
    app.kubernetes.io/name: {{ include "jaeger.name" . }}
    helm.sh/chart: {{ include "jaeger.chart" . }}
    app.kubernetes.io/component: collector
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.collector.service.annotations }}
  annotations:
{{ toYaml .Values.collector.service.annotations | indent 4 }}
{{- end }}
spec:
  ports:
  - name: grpc
    port: {{ .Values.collector.service.grpcPort }}
    protocol: TCP
    targetPort: grpc
  - name: tchannel
    port: {{ .Values.collector.service.tchannelPort }}
    protocol: TCP
    targetPort: tchannel
  - name: http
    port: {{ .Values.collector.service.httpPort }}
    protocol: TCP
    targetPort: http
  - name: zipkin
    port: {{ .Values.collector.service.zipkinPort }}
    protocol: TCP
    targetPort: zipkin
  selector:
    app.kubernetes.io/name: {{ include "jaeger.name" . }}
    app.kubernetes.io/component: collector
    app.kubernetes.io/instance: {{ .Release.Name }}
  type: {{ .Values.collector.service.type }}
{{- template "loadBalancerSourceRanges" .Values.collector }}
{{- end -}}
