{{- if .Values.global.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ include "model-serving.fullname" . }}
  annotations:
    kubernetes.io/ingress.class: {{ .Values.global.ingress.className | quote }}
spec:
  {{- if .Values.global.ingress.tls }}
  tls:
    - hosts:
        - {{ .Values.global.ingress.host | quote }}
      secretName: {{ .Values.global.ingress.tlsSecretName | quote }}
  {{- end }}
  rules:
    - host: {{ .Values.global.ingress.host | quote }}
      http:
        paths:
        {{- range .Values.models }}
          - path: /{{ .path }}
            pathType: Prefix
            backend:
              service:
                name: {{ include "model-serving.fullname" $ }}-{{ .name }}
                port:
                  number: {{ $.Values.service.port | default 80 }}
        {{- end }}
{{- end }}
