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

apiVersion: v1
kind: Service
metadata:
  name: {{ printf "%s-headless" (include "victoriametrics.vmstorage.fullname" .) | trunc 63 | trimSuffix "-" }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/part-of: victoriametrics
    app.kubernetes.io/component: vmstorage
  {{- if or .Values.commonAnnotations .Values.vmstorage.service.headless.annotations }}
  {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.vmstorage.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
      port: {{ .Values.vmstorage.containerPorts.http }}
      targetPort: http
      protocol: TCP
    - name: tcp-vminsert
      port: {{ .Values.vmstorage.containerPorts.vminsert }}
      targetPort: tcp-vminsert
      protocol: TCP
    - name: tcp-vmselect
      port: {{ .Values.vmstorage.containerPorts.vmselect }}
      targetPort: tcp-vmselect
      protocol: TCP
  selector: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: vmstorage
