apiVersion: v1
kind: Service
metadata:
  name: {{ include "ambassador.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "ambassador.name" . }}
    app.kubernetes.io/part-of: {{ .Release.Name }}
    helm.sh/chart: {{ include "ambassador.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/component: ambassador-service
  {{- if .Values.extraLabels }}
    {{- toYaml .Values.extraLabels | nindent 4 }}
  {{- end }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.service.type }}
  {{- if .Values.service.loadBalancerIP }}
  loadBalancerIP: "{{ .Values.service.loadBalancerIP }}"
  {{- end }}
  {{- if .Values.service.externalTrafficPolicy }}
  externalTrafficPolicy: "{{ .Values.service.externalTrafficPolicy }}"
  {{- end }}
  ports:
    {{- toYaml .Values.service.ports | nindent 4 }}
  selector:
    app.kubernetes.io/name: {{ include "ambassador.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
  {{- with .Values.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
    {{- toYaml . | nindent 4 }}
  {{- end }}
