{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

apiVersion: v1
kind: Service
metadata:
  name: {{ template "dremio.headlessServiceName" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/part-of: dremio
  {{- if or .Values.commonAnnotations .Values.service.headless.annotations }}
  {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.headless.annotations .Values.commonAnnotations ) "context" . ) }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
  {{- end }}
spec:
  type: ClusterIP
  publishNotReadyAddresses: true
  clusterIP: None
  ports:
    - name: http-web
      port: {{ .Values.dremio.containerPorts.web }}
      targetPort: web
      protocol: TCP
    - name: tcp-client
      port: {{ .Values.dremio.containerPorts.client }}
      targetPort: client
      protocol: TCP
    - name: tcp-flight
      port: {{ .Values.dremio.containerPorts.flight }}
      targetPort: flight
      protocol: TCP
    - name: tcp-fabric
      port: {{ .Values.dremio.containerPorts.fabric }}
      targetPort: fabric
      protocol: TCP
    - name: tcp-conduit
      port: {{ .Values.dremio.containerPorts.conduit }}
      targetPort: conduit
      protocol: TCP
    - name: tcp-liveness
      port: {{ .Values.dremio.containerPorts.liveness }}
      targetPort: conduit
      protocol: TCP
    - name: tcp-jmx
      port: {{ .Values.dremio.containerPorts.jmx }}
      targetPort: jmx
      protocol: TCP
  selector: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/part-of: dremio
