{{- include "nplus.init" $ -}}
{{- if or (.Values.components).nappl (.Values.components).nappljobs -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ .component.prefix }}nappl-cluster
  {{- if .this.utils.includeNamespace }}
  namespace: {{ .Release.Namespace }}
  {{- end }}
  labels:
    {{- include "nplus.instanceLabels" . | nindent 4 }}
  annotations:
    {{- include "nplus.argoWave" . | nindent 4 }}
    {{- include "nplus.annotations" . | nindent 4 }}
    {{- include "nplus.securityAnnotations" . | nindent 4 }}
spec:

  # this is a "headless service", no cluster IP is defined
  # as none of the internal components need to access this service.
  # It is purely used to collect the EndPointSlices
  type: ClusterIP
  clusterIP: None

  ports:
  {{- if not (.this.security).zeroTrust }}
  - name: http
    port: 8080
    targetPort: http
    protocol: TCP
  {{- end }}
  - name: https
    port: 8443
    targetPort: https
    protocol: TCP

  selector:
    nplus/group: {{ .instance.group }}
    nplus/type: core
{{- end -}}