{{- if and .Values.server.enabled (not .Values.server.statefulSet.enabled) -}}
apiVersion: v1
kind: Service
metadata:
  namespace: {{ .Release.Namespace }}
{{- if .Values.server.service.annotations }}
  annotations:
{{ toYaml .Values.server.service.annotations | indent 4}}
{{- end }}
  labels:
    {{- include "victoria-logs.server.labels" . | nindent 4 }}
{{- if .Values.server.service.labels }}
{{ toYaml .Values.server.service.labels | indent 4}}
{{- end }}
  name: {{ template "victoria-logs.server.fullname" . }}
spec:
{{- if .Values.server.service.clusterIP }}
  clusterIP: {{ .Values.server.service.clusterIP }}
{{- end }}
{{- if .Values.server.service.externalIPs }}
  externalIPs:
{{ toYaml .Values.server.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.server.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.server.service.loadBalancerIP }}
{{- end }}
{{- if .Values.server.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
  {{- range $cidr := .Values.server.service.loadBalancerSourceRanges }}
    - {{ $cidr }}
  {{- end }}
{{- end }}
  ports:
    - name: http
      port: {{ .Values.server.service.servicePort }}
      protocol: TCP
      targetPort: http
      {{- with .Values.server.service.nodePort }}
      nodePort: {{ . }}
      {{- end }}
  selector:
    {{- include "victoria-logs.server.matchLabels" . | nindent 4 }}
  type: "{{ .Values.server.service.type }}"
  {{- with .Values.server.service.healthCheckNodePort }}
  healthCheckNodePort: {{ . }}
  {{- end }}
  {{- with .Values.server.service.externalTrafficPolicy }}
  externalTrafficPolicy: {{ . }}
  {{- end }}
{{- end }}
