{{- if .Values.service }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "fluentd-elasticsearch.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "fluentd-elasticsearch.name" . }}
    helm.sh/chart: {{ include "fluentd-elasticsearch.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  type: {{ .Values.service.type }}
  ports:
  {{- range $port := .Values.service.ports }}
    - name: {{ $port.name }}
      port: {{ $port.port }}
      targetPort: {{ $port.port }}
      {{- if $port.nodePort }}
      nodePort: {{ $port.nodePort }}
      {{- end }}
      {{- if $port.protocol }}
      protocol: {{ $port.protocol }}
      {{- end }}
  {{- end }}
  selector:
    app.kubernetes.io/name: {{ include "fluentd-elasticsearch.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
