{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ include "kserve.fullname" . }}
  namespace: {{ .Values.ingress.namespace }}
  labels:
    {{- include "kserve.labels" . | nindent 4 }}
  annotations:
    {{- toYaml .Values.ingress.annotations | nindent 4 }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  rules:
    {{- range .Values.ingress.hosts }}
    - host: {{ .host }}
      http:
        paths:
          - backend:
              service:
                name: {{ $.Values.ingress.backend.service.name }}
                port:
                  number: {{ $.Values.ingress.backend.service.port }}
            path: /
            pathType: Prefix
    {{- end }}
  {{- if .Values.ingress.tls.enabled }}
  tls:
    - hosts:
      {{- range .Values.ingress.hosts }}
        - {{ .host }}
      {{- end }}
      secretName: {{ .Values.ingress.tls.secretName }}
  {{- end }}
{{- end }}