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

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