{{- if .Values.frontend.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: navix-frontend
  annotations:
    {{- range $key, $value := .Values.frontend.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  ingressClassName: {{ .Values.frontend.ingress.className }}
  rules:
    {{- range .Values.frontend.ingress.hosts }}
    - host: {{ .host }}
      http:
        paths:
          {{- range .paths }}
          - path: {{ .path }}
            pathType: {{ .pathType }}
            backend:
              service:
                name: navix-frontend
                port:
                  number: {{ $.Values.frontend.service.port }}
          {{- end }}
    {{- end }}
{{- end }}

---

{{- if .Values.backend.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: navix-backend
  annotations:
    {{- range $key, $value := .Values.backend.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  ingressClassName: {{ .Values.backend.ingress.className }}
  rules:
    {{- range .Values.backend.ingress.hosts }}
    - host: {{ .host }}
      http:
        paths:
          {{- range .paths }}
          - path: {{ .path }}
            pathType: {{ .pathType }}
            backend:
              service:
                name: navix-backend
                port:
                  number: {{ $.Values.backend.service.port }}
          {{- end }}
    {{- end }}
{{- end }}
