{{/* One Ingress object per app whose ingress is enabled, each with its own host and its own TLS secret. The hosts are independent values - they do not have to share a domain - and each ingress points at its own app's service. .ingress.host is required, but only for an app whose ingress is actually enabled: the required call sits inside the loop over the enabled apps, so turning an app's ingress off must never make the chart demand a host for it. */}} {{- if .Values.ingress.enabled }} {{- range $app := include "freesailarr.ingressApps" $ | fromJsonArray }} {{- $config := (index $.Values $app.name).ingress }} {{- /* clusterIssuer, className and annotations default to the global ingress block and are overridable per app; an explicitly set per-app value wins even when it is empty, hence the nil check instead of "default". */}} {{- $clusterIssuer := $.Values.ingress.clusterIssuer }} {{- if not (kindIs "invalid" $config.clusterIssuer) }}{{- $clusterIssuer = $config.clusterIssuer }}{{- end }} {{- $className := $.Values.ingress.className }} {{- if not (kindIs "invalid" $config.className) }}{{- $className = $config.className }}{{- end }} {{- $annotations := $.Values.ingress.annotations }} {{- if not (kindIs "invalid" $config.annotations) }}{{- $annotations = $config.annotations }}{{- end }} {{- $host := required (printf "%s.ingress.host must be provided while %s.ingress.enabled is true" $app.name $app.name) $config.host }} --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ $.Release.Name }}-{{ $.Chart.Name }}-{{ $app.name }}-ingress annotations: cert-manager.io/cluster-issuer: {{ required "A Cluster-Issuer must be provided" $clusterIssuer }} {{- with $annotations }} {{- toYaml . | nindent 4 }} {{- end }} spec: ingressClassName: {{ $className }} rules: - host: {{ $host | quote }} http: paths: - backend: service: name: {{ $.Release.Name }}-{{ $.Chart.Name }}-{{ $app.name }}-service port: name: {{ $app.name }} path: / pathType: Prefix tls: - hosts: - {{ $host | quote }} secretName: tls-{{ $.Release.Name }}-{{ $.Chart.Name }}-{{ $app.name }}-ingress {{- end }} {{- end }}