# helm_charts_monitoring-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ template "nats.fullname" . }}-monitoring
  labels:
    app: "{{ template "nats.name" . }}"
    chart: "{{ template "nats.chart" . }}"
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
  {{- if .Values.monitoring.service.annotations }}
  annotations:
{{ toYaml .Values.monitoring.service.annotations | indent 4 }}
  {{- end }}
spec:
  type: {{ .Values.monitoring.service.type }}
  {{- if and (eq .Values.monitoring.service.type "LoadBalancer") .Values.monitoring.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.monitoring.service.loadBalancerIP }}
  {{- end }}
  ports:
    - port: {{ .Values.monitoring.service.port }}
      targetPort: monitoring
      name: monitoring
      {{- if and (eq .Values.monitoring.service.type "NodePort") (not (empty .Values.monitoring.service.nodePort)) }}
      nodePort: {{ .Values.monitoring.service.nodePort  }}
      {{- end }}
  selector:
    app: "{{ template "nats.name" . }}"
    release: {{ .Release.Name | quote }}