apiVersion: v1
kind: Service
metadata:
  {{- if .this.utils.includeNamespace }}
  namespace: {{ .Release.Namespace }}
  {{- end }}
  name: {{ .component.fullName }}-admin
  labels:
    {{- include "nplus.instanceLabels" . | nindent 4 }}
  annotations:
    {{- include "nplus.argoWave" . | nindent 4 }}
    {{- include "nplus.annotations" . | nindent 4 }}
    {{- include "nplus.securityAnnotations" . | nindent 4 }}
    {{- include "nplus.serviceAnnotations" . | nindent 4 }}
spec:
  selector:
  {{- if eq .this.service.selector "component" }}
    {{- include "nplus.selectorLabels" . | nindent 4 }}
  {{- else if eq .this.service.selector "type" }}
    {{- include "nplus.selectorLabelsNc" . | nindent 4 }}
  {{- else }}
    {{- fail (printf "Unknown Service Selector Type: %s - must be component or type" .this.service.selector) }}
  {{- end }}
  type: LoadBalancer
  {{- if .Values.externalIp }}
  loadBalancerIP: {{ .Values.externalIp }}
  {{- end }}
  ports:
    - protocol: TCP
      port: 3120
      targetPort: 3120
      name: rms

    {{- range $ckey, $component := .Values.comps }}
    {{- if $component.enabled }}
    {{- range $pkey, $port := .ports }}
    - protocol: TCP
      port: {{ $port }}
      targetPort: {{ $port }}
      name: {{ $ckey }}-{{ $pkey }}
    {{- end }}
    {{- end }}
    {{- end }}
