{{- if .Values.metrics.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "fluentd.fullname" . }}-metrics
  labels: {{- include "fluentd.labels" . | nindent 4 }}
    app: metrics
  annotations: {{- include "fluentd.tplValue" (dict "value" .Values.metrics.service.annotations "context" $) | nindent 4 }}
spec:
  type: {{ .Values.metrics.service.type }}
  {{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }}
  {{- end }}
  ports:
    - name: tcp-metrics
      port: {{ .Values.metrics.service.port }}
  selector: {{- include "fluentd.matchLabels" . | nindent 4 }}
{{- end }}
