{{- if .Values.webui.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ include "open-webui.name" . }}
  labels:
    {{- include "open-webui.labels" . | nindent 4 }}
  {{- with .Values.webui.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- with .Values.webui.ingress.class }}
  ingressClassName: {{ . }}
  {{- end }}
  {{- if .Values.webui.ingress.tls }}
  tls:
    - hosts:
      - {{ .Values.webui.ingress.host | quote }}
      secretName: {{ default (printf "%s-tls" .Release.Name) .Values.webui.ingress.existingSecret }}
  {{- end }}
  rules:
  - host: {{ .Values.webui.ingress.host }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: {{ include "open-webui.name" . }}
            port:
              name: http
{{- end }}
