{{- if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ include "common.names.fullname" . }}-ingress
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: ingress
  annotations:
    {{- if .Values.ingress.certManager }}
    kubernetes.io/tls-acme: "true"
    {{- end }}
    {{- range $key, $value := .Values.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
{{- end }}
spec:
  rules:
    {{- range .Values.ingress.hosts }}
    - host: {{ .name }}
      http:
        paths:
          - path: {{ default "/" .path }}
            backend:
              serviceName: {{ include "spark.master.service.name" $ }}
              servicePort: http
    {{- end }}
  {{- if .Values.ingress.tls }}
  tls:
  {{- range $i, $tls := .Values.ingress.tls }}
    - hosts:
      {{- range $e, $host := $tls.hosts }}
        - {{ $host }}
      {{ end -}}
      secretName: {{ $tls.secretName }}
  {{ end -}}
  {{- end -}}
{{- end }}
