# helm_charts_spark-zeppelin-ingress.yaml
{{- $ingress := .Values.Zeppelin.Ingress -}}
{{- $fullName := include "zeppelin-fullname" . -}}
{{- if $ingress.Enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "zeppelin-fullname" . }}
{{- if $ingress.Annotations }}
  annotations:
{{ toYaml $ingress.Annotations | indent 4 }}
{{- end }}
  labels:
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    component: "{{ .Release.Name }}-{{ .Values.Zeppelin.Component }}"
spec:
{{- if $ingress.Tls }}
  tls:
  {{- range $ingress.Tls }}
  - hosts:
    {{- range .Hosts }}
    - {{ . }}
    {{- end }}
    secretName: {{ .SecretName | default (printf "%s-tls" $fullName) }}
{{- end }}
{{- end }}
  {{- if $ingress.Hosts }}
  rules:
  {{- range $ingress.Hosts }}
  - host: {{ . }}
    http:
      paths:
      - path: {{ $ingress.Path }}
        backend:
          serviceName: {{ $fullName }}
          servicePort: http
  {{- end }}
{{- else }}
  backend:
    serviceName: {{ template "zeppelin-fullname" . }}
    servicePort: http
{{- end }}
{{- end }}