{{- if eq .Values.architecture "high-availability" }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "common.names.fullname" . }}-headless
  labels:
    {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: influxdb
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if or .Values.influxdb.service.annotations .Values.commonAnnotations }}
  annotations:
    {{- if .Values.commonAnnotations }}
    {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
    {{- end }}
    {{- if .Values.influxdb.service.annotations }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.influxdb.service.annotations "context" $) | nindent 4 }}
    {{- end }}
  {{- end }}
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - port: {{ coalesce .Values.influxdb.service.ports.http .Values.influxdb.service.port }}
      targetPort: http
      protocol: TCP
      name: http
    - port: {{ coalesce .Values.influxdb.service.ports.rpc .Values.influxdb.service.rpcPort }}
      targetPort: rpc
      protocol: TCP
      name: rpc
  selector:
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: influxdb
{{- end }}
