apiVersion: v1
kind: Service
metadata:
  name: {{ include "azure-api-management-gateway.fullname" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels:
    {{- include "azure-api-management-gateway.labels" . | nindent 4 }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.service.type }}
{{- if eq .Values.service.type "LoadBalancer" }}
{{- if (.Values.service.loadBalancer).ip }}
  loadBalancerIP: {{ .Values.service.loadBalancer.ip }}
{{- end }}
{{- if eq .Values.service.loadBalancer.allocateNodePorts false }}
  allocateLoadBalancerNodePorts: false
{{- end }}
{{- end }}
  ports:
    - port: {{ .Values.service.ports.http }}
      targetPort: http
      protocol: TCP
      name: http
    - port: {{ .Values.service.ports.https }}
      targetPort: https
      protocol: TCP
      name: https
  selector:
    {{- include "azure-api-management-gateway.selectorLabels" . | nindent 4 }}
