{{- if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: longhorn-ingress
  labels: {{- include "longhorn.labels" . | nindent 4 }}
    app: longhorn-ingress
  annotations:
    {{- if .Values.ingress.tls }}
    ingress.kubernetes.io/secure-backends: "true"
    {{- end }}
    {{- range $key, $value := .Values.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  rules:
  - host: {{ .Values.ingress.host }}
    http:
      paths:
        - path: {{ default "" .Values.ingress.path }}
          backend:
            serviceName: longhorn-frontend
            servicePort: 80
{{- if .Values.ingress.tls }}
  tls:
  - hosts:
    - {{ .Values.ingress.host }}
    secretName: {{ .Values.ingress.tlsSecret }}
{{- end }}
{{- end }}
