{{- if .Values.ingress.enabled -}}
{{- $fullname := include "spark-history-server.fullname" . -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ $fullname }}
  labels:
    app.kubernetes.io/name: {{ include "spark-history-server.name" . }}
    helm.sh/chart: {{ include "spark-history-server.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
  annotations:
{{- range $key, $value := .Values.ingress.annotations }}
      {{ $key }}: {{ $value | quote }}
{{- end }}
spec:
  rules:
    {{- range $host := .Values.ingress.hosts }}
    - host: {{ $host }}
      http:
        paths:
        - path: {{ $.Values.ingress.path }}
          backend:
            serviceName: {{ $fullname }}
            servicePort: {{ .Values.service.port.number }}
    {{- end -}}
  {{- if .Values.ingress.tls }}
  tls:
  {{- range .Values.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . | quote }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end -}}
{{- end -}}
