# helm_charts_admin-service.yaml
{{- if .Values.adminService.create -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "ambassador.fullname" . }}-admin
  labels:
    app.kubernetes.io/name: {{ include "ambassador.name" . }}
    helm.sh/chart: {{ include "ambassador.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/part-of: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
  {{- if .Values.extraLabels }}
    {{- toYaml .Values.extraLabels | nindent 4 }}
  {{- end }}
  {{- with .Values.adminService.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.adminService.type }}
  ports:
    - port: {{ .Values.adminService.port }}
      targetPort: admin
      protocol: TCP
      name: admin
      {{- if (and (eq .Values.adminService.type "NodePort") (not (empty .Values.adminService.nodePort))) }}
      nodePort: {{ .Values.adminService.nodePort }}
      {{- end }}
  selector:
    app.kubernetes.io/name: {{ include "ambassador.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
  {{- if eq .Values.adminService.type "LoadBalancer" }}
  {{- if not (empty .Values.adminService.loadBalancerIP) }}
  loadBalancerIP: {{ .Values.adminService.loadBalancerIP | quote }}
  {{- end }}
  {{- if not (empty .Values.adminService.loadBalancerSourceRanges) }}
  loadBalancerSourceRanges:
    {{- toYaml .Values.adminService.loadBalancerSourceRanges | nindent 4 }}
  {{- end }}
  {{- end }}
{{- end -}}