{{- range $processName, $config := .Values.processes }} {{- if not (hasKey $config "web") }} # Skip {{ $processName }} as it doesn't have a web section {{- continue }} {{- end }} {{- $routeToKeda := false }} {{- if and $config.autoscaling (and $config.autoscaling.enabled (eq $config.autoscaling.type "keda")) }} {{- if and ($.Capabilities.APIVersions.Has "http.keda.sh/v1alpha1") (and $config.autoscaling.http_trigger (eq $config.autoscaling.http_trigger.type "http")) }} {{- $routeToKeda = true }} {{- end }} {{- end }} {{- if and $config.web.domains (eq $.Values.global.network.ingress_class "nginx") }} {{- range $pdx, $domain := $config.web.domains }} --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: dokku.com/managed: "true" dokku.com/ingress-method: "domains" {{- if $config.web.tls.enabled }} nginx.ingress.kubernetes.io/force-ssl-redirect: "true" {{- end }} {{ include "print.annotations" (dict "config" $.Values.global "key" "ingress") | indent 4 }} {{ include "print.annotations" (dict "config" $config "key" "ingress") | indent 4 }} labels: app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }} app.kubernetes.io/name: {{ $processName }} app.kubernetes.io/part-of: {{ $.Values.global.app_name }} {{ include "print.labels" (dict "config" $.Values.global "key" "ingress") | indent 4 }} {{ include "print.labels" (dict "config" $config "key" "ingress") | indent 4 }} name: {{ $.Values.global.app_name }}-{{ $processName }}-{{ $domain.slug }} namespace: {{ $.Values.global.namespace }} spec: ingressClassName: nginx {{- if $config.web.tls.enabled }} tls: - hosts: - {{ $domain.name | quote }} {{- if $config.web.tls.use_imported_cert }} secretName: tls-{{ $.Values.global.app_name }} {{- else }} secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }} {{- end }} {{- end }} rules: - host: {{ $domain.name | quote }} http: paths: {{- if $config.web.port_maps }} - backend: {{- if $routeToKeda}} service: name: kip-{{ $.Values.global.app_name}}-{{ $processName }} port: number: 8080 pathType: Prefix {{- else }} service: name: {{ $.Values.global.app_name }}-{{ $processName }} port: name: {{ include "primary.port" $config.web.port_maps }} pathType: ImplementationSpecific {{- end }} path: / {{- end }} {{- range $rdx, $route := $.Values.global.network.routes }} {{- if not $route.strip_prefix }} - backend: service: name: {{ $.Values.global.app_name }}-{{ $route.process }} port: number: {{ $route.port }} pathType: Prefix path: {{ $route.path }} {{- end }} {{- end }} {{- end }} {{- end }} {{- end }} {{- /* Strip-prefix routes need their own Ingress objects because the rewrite-target annotation is Ingress-level. */}} {{- range $processName, $config := .Values.processes }} {{- if not (hasKey $config "web") }} {{- continue }} {{- end }} {{- if and $config.web.domains (eq $.Values.global.network.ingress_class "nginx") }} {{- range $pdx, $domain := $config.web.domains }} {{- range $rdx, $route := $.Values.global.network.routes }} {{- if $route.strip_prefix }} --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: dokku.com/managed: "true" dokku.com/ingress-method: "routes" nginx.ingress.kubernetes.io/rewrite-target: /$2 {{- if $config.web.tls.enabled }} nginx.ingress.kubernetes.io/force-ssl-redirect: "true" {{- end }} {{ include "print.annotations" (dict "config" $.Values.global "key" "ingress") | indent 4 }} {{ include "print.annotations" (dict "config" $config "key" "ingress") | indent 4 }} labels: app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $route.process }} app.kubernetes.io/name: {{ $route.process }} app.kubernetes.io/part-of: {{ $.Values.global.app_name }} {{ include "print.labels" (dict "config" $.Values.global "key" "ingress") | indent 4 }} {{ include "print.labels" (dict "config" $config "key" "ingress") | indent 4 }} name: {{ $.Values.global.app_name }}-{{ $route.process }}-{{ $route.slug }}-strip-{{ $domain.slug }} namespace: {{ $.Values.global.namespace }} spec: ingressClassName: nginx {{- if $config.web.tls.enabled }} tls: - hosts: - {{ $domain.name | quote }} {{- if $config.web.tls.use_imported_cert }} secretName: tls-{{ $.Values.global.app_name }} {{- else }} secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }} {{- end }} {{- end }} rules: - host: {{ $domain.name | quote }} http: paths: - backend: service: name: {{ $.Values.global.app_name }}-{{ $route.process }} port: number: {{ $route.port }} pathType: ImplementationSpecific path: {{ $route.path }}(/|$)(.*) {{- end }} {{- end }} {{- end }} {{- end }} {{- end }}