apiVersion: v1
kind: Service
metadata:
{{- if .Values.data.service.annotations }}
  annotations:
{{ toYaml .Values.data.service.annotations | indent 4 }}
{{- end }}
  name: {{ template "influxdb-enterprise.fullname" . }}-data
  labels:
    influxdb.influxdata.com/component: data
    {{- include "influxdb-enterprise.labels" . | nindent 4 }}
spec:
  type: {{ .Values.data.service.type }}
{{- if (eq "ClusterIP" .Values.data.service.type) }}
  clusterIP: None
{{- end }}
  publishNotReadyAddresses: true
  ports:
  - port: 8086
    protocol: TCP
    name: http
{{- if .Values.data.service.nodePort }}
    nodePort: {{ .Values.data.service.nodePort }}
{{- end }}
  - port: 8088
    protocol: TCP
    name: rpc
  - port: 2003
    # Graphite supports TCP and UDP,
    # so this should __maybe__ be configurable
    # Though most use TCP
    protocol: TCP
    name: graphite
  - port: 4242
    protocol: TCP
    name: opentsdb
    # LoadBalancer service type only allows for one protocol
    # disbaling UDP ports
{{- if (ne "LoadBalancer" .Values.data.service.type) }}
  - port: 25826
    protocol: UDP
    name: collectd
  - port: 8089
    protocol: UDP
    name: udp
{{- end }}
  selector:
    influxdb.influxdata.com/component: data
{{- include "influxdb-enterprise.selectorLabels" . | nindent 4 }}
{{- if .Values.data.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.data.service.loadBalancerIP }}
{{- end }}
{{- if .Values.data.service.externalIPs }}
  externalIPs:
{{ toYaml .Values.data.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.data.service.externalTrafficPolicy }}
  externalTrafficPolicy: {{ .Values.data.service.externalTrafficPolicy }}
{{- end }}