apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
  name: {{ include "influxdb.fullname" . }}
  labels:
    {{- include "influxdb.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
  - name: api
    port: {{ .Values.config.http.bind_address | default 8086 }}
    targetPort: api
  - name: rpc
    port: {{ .Values.config.rpc.bind_address | default 8088 }}
    targetPort: rpc
  {{- if .Values.config.graphite.enabled }}
  - name: graphite
    port: {{ .Values.config.graphite.bind_address | default 2003 }}
    targetPort: graphite
  {{- end }}
  {{- if .Values.config.collectd.enabled }}
  - name: collectd
    port: {{ .Values.config.collectd.bind_address |  default 25826 }}
    targetPort: collectd
  {{- end }}
  {{- if .Values.config.udp.enabled }}
  - name: udp
    port: {{ .Values.config.udp.bind_address |  default 8089 }}
    targetPort: udp
  {{- end }}
  {{- if .Values.config.opentsdb.enabled }}
  - name: opentsdb
    port: {{ .Values.config.opentsdb.bind_address |  default 4242 }}
    targetPort: opentsdb
  {{- end }}
  selector:
    {{- include "influxdb.selectorLabels" . | nindent 4 }}
