{{- range .Values.additionalIngresses }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ $.Release.Name }}-{{ .name }}
  labels:
    app.kubernetes.io/name: {{ $.Values.appName }}
    app.kubernetes.io/instance: {{ $.Release.Name }}
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    {{- with $.Values.ingress.clusterIssuer }}
    cert-manager.io/cluster-issuer: {{ . }}
    {{- end }}
    {{- with .annotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
spec:
  tls:
    - hosts:
        - {{ .host }}
      {{- if $.Values.ingress.tlsSecret }}
      secretName: {{ $.Release.Name }}-{{ .name }}-tls
      {{- end }}
  rules:
  - host: {{ .host }}
    http:
      paths:
      - path: {{ .path }}
        pathType: Prefix
        backend:
          service:
            name: {{ $.Release.Name }}
            port:
              number: {{ $.Values.port }}
{{- end }}
