# helm_charts_service-kong-portal-api.yaml
{{- if .Values.enterprise.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "kong.fullname" . }}-portalapi
  annotations:
    {{- range $key, $value := .Values.portalapi.annotations }}
      {{ $key }}: {{ $value | quote }}
    {{- end }}
  labels:
    {{- include "kong.metaLabels" . | nindent 4 }}
spec:
  type: {{ .Values.portalapi.type }}
  {{- if eq .Values.portalapi.type "LoadBalancer" }}
  {{- if .Values.portalapi.loadBalancerIP }}
  loadBalancerIP: {{ .Values.portalapi.loadBalancerIP }}
  {{- end }}
  {{- if .Values.portalapi.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
  {{- range $cidr := .Values.portalapi.loadBalancerSourceRanges }}
  - {{ $cidr }}
  {{- end }}
  {{- end }}
  {{- end }}
  externalIPs:
  {{- range $ip := .Values.portalapi.externalIPs }}
  - {{ $ip }}
  {{- end }}
  ports:
  {{- if .Values.portalapi.http.enabled }}
  - name: kong-portalapi
    port: {{ .Values.portalapi.http.servicePort }}
    targetPort: {{ .Values.portalapi.http.containerPort }}
  {{- if (and (eq .Values.portalapi.type "NodePort") (not (empty .Values.portalapi.http.nodePort))) }}
    nodePort: {{ .Values.portalapi.http.nodePort }}
  {{- end }}
    protocol: TCP
  {{- end }}
  {{- if or .Values.portalapi.tls.enabled }}
  - name: kong-portalapi-tls
    port: {{ .Values.portalapi.tls.servicePort }}
    targetPort: {{ .Values.portalapi.tls.containerPort }}
  {{- if (and (eq .Values.portalapi.type "NodePort") (not (empty .Values.portalapi.tls.nodePort))) }}
    nodePort: {{ .Values.portalapi.tls.nodePort }}
  {{- end }}
    protocol: TCP
  {{- end }}
  selector:
    {{- include "kong.selectorLabels" . | nindent 4 }}
{{- end -}}