{{- if and .Values.server.enabled .Values.server.statefulSet.enabled -}}
apiVersion: v1
kind: Service
metadata:
  namespace: {{ .Release.Namespace }}
{{- if .Values.server.statefulSet.service.annotations }}
  annotations:
{{ toYaml .Values.server.statefulSet.service.annotations | indent 4}}
{{- end }}
  labels:
  {{- include "victoria-logs.server.labels" . | nindent 4 }}
{{- if .Values.server.statefulSet.service.labels }}
{{ toYaml .Values.server.statefulSet.service.labels | indent 4}}
{{- end }}
  name: {{ template "victoria-logs.server.fullname" . }}
spec:
  clusterIP: None
  {{- with .Values.server.statefulSet.service.healthCheckNodePort }}
  healthCheckNodePort: {{ . }}
  {{- end }}
  {{- with .Values.server.statefulSet.service.externalTrafficPolicy }}
  externalTrafficPolicy: {{ . }}
  {{- end }}
  ports:
    - name: http
      port: {{ .Values.server.statefulSet.service.servicePort }}
      protocol: TCP
      targetPort: http
  selector:
    {{- include "victoria-logs.server.matchLabels" . | nindent 4 }}
{{- end -}}
