apiVersion: v1
kind: Service
metadata:
  name: {{ template "prometheus-node-exporter.fullname" . }}
  namespace: {{ template "prometheus-node-exporter.namespace" . }}
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
  labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
    {{- if ( and (eq .Values.service.type "NodePort" ) (not (empty .Values.service.nodePort)) ) }}
      nodePort: {{ .Values.service.nodePort }}
    {{- end }}
      targetPort: {{ .Values.service.targetPort }}
      protocol: TCP
      name: metrics
  selector:
    app: {{ template "prometheus-node-exporter.name" . }}
    release: {{ .Release.Name }}
