{{- if and .Values.aggregator.enabled .Values.aggregator.service.ports -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "common.names.fullname" . }}-headless
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: aggregator
    app: aggregator
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  annotations: 
    {{- if or .Values.commonAnnotations }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
    {{- end }}
    {{- if .Values.aggregator.service.annotationsHeadless }}
    {{- include "common.tplvalues.render" (dict "value" .Values.aggregator.service.annotationsHeadless "context" $) | nindent 4 }}
    {{- end }}
spec:
  type: ClusterIP
  clusterIP: None
  ports:
  {{- range $key, $value := .Values.aggregator.service.ports }}
    - name: {{ $key }}
      {{ omit $value "nodePort" | toYaml | nindent 6 }}
  {{- end }}
  selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: aggregator
{{- end -}}
