apiVersion: v1
kind: Service
metadata:
  name: {{ include "goldpinger.fullname" . }}
  labels:
    {{- include "goldpinger.labels" . | nindent 4 }}
{{- with .Values.service.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.goldpinger.port }}
      protocol: TCP
      name: http
    {{- if .Values.goldpinger.udp.enabled }}
    - port: {{ .Values.goldpinger.udp.port }}
      targetPort: {{ .Values.goldpinger.udp.port }}
      protocol: UDP
      name: udp-probe
    {{- end }}
  selector:
    {{- include "goldpinger.selectorLabels" . | nindent 4 }}
  {{- if .Values.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
    {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
  {{- end }}
