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