# helm_charts_udp-service.yaml
{{- if .Values.graylog.input.udp }}
apiVersion: v1
kind: Service
metadata:
{{- if .Values.graylog.input.udp.service.annotations }}
  annotations:
{{ toYaml .Values.graylog.input.udp.service.annotations | indent 4 }}
{{- end }}
  name: {{ template "graylog.fullname" . }}-udp
  labels:
{{ include "graylog.metadataLabels" . | indent 4 }}
    app.kubernetes.io/component: "UDP"
spec:
  ports:
  {{- range .Values.graylog.input.udp.ports }}
    - name: {{ .name }}
      port: {{ .port }}
      protocol: UDP
      targetPort: {{ .port }}
    {{- if eq "NodePort" $.Values.graylog.input.udp.service.type }}
      {{- if .nodePort }}
      nodePort:  {{ .nodePort }}
      {{- end }}
    {{- end }}
  {{- end }}
{{- if .Values.graylog.input.udp.service.externalIPs }}
  externalIPs:
{{ toYaml .Values.graylog.input.udp.service.externalIPs | indent 4 }}
{{- end }}
{{- if eq "ClusterIP" .Values.graylog.input.udp.service.type }}
  {{- if .Values.graylog.input.udp.service.clusterIP }}
  clusterIP:  {{ .Values.graylog.input.udp.service.clusterIP }}
  {{- end }}
{{- end }}  
  selector:
    app.kubernetes.io/name: {{ template "graylog.name" . }}
    app.kubernetes.io/instance: "{{ .Release.Name }}"
  type: "{{ .Values.graylog.input.udp.service.type }}"
{{- if eq "LoadBalancer" .Values.graylog.input.udp.service.type }}
  externalTrafficPolicy: {{ .Values.graylog.input.udp.service.externalTrafficPolicy | default "Cluster" }}
  {{- if .Values.graylog.input.udp.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.graylog.input.udp.service.loadBalancerIP }}
  {{- end -}}
  {{- if .Values.graylog.input.udp.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
  {{- range .Values.graylog.input.udp.service.loadBalancerSourceRanges }}
  - {{ . }}
  {{- end }}
  {{- end -}}
{{- end -}}
{{- end }}