{{- if .Values.ingressInternal.enabled }} {{- $appActive := .Values.app.enabled -}} {{- $realtimeActive := .Values.realtime.enabled -}} {{- $hasCopilotIngress := and .Values.copilot.enabled .Values.ingressInternal.copilot -}} {{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host)) -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "sim.fullname" . }}-ingress-internal namespace: {{ .Release.Namespace }} labels: {{- include "sim.labels" . | nindent 4 }} {{- with .Values.ingressInternal.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: {{- if .Values.ingressInternal.className }} ingressClassName: {{ .Values.ingressInternal.className }} {{- end }} {{- if .Values.ingressInternal.tls.enabled }} tls: - hosts: {{- if $appActive }} - {{ .Values.ingressInternal.app.host | quote }} {{- end }} {{- if $realtimeHasOwnRule }} - {{ .Values.ingressInternal.realtime.host | quote }} {{- end }} {{- if $hasCopilotIngress }} {{- $copilotHostCovered := false }} {{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} {{- $copilotHostCovered = true }} {{- end }} {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }} {{- $copilotHostCovered = true }} {{- end }} {{- if not $copilotHostCovered }} - {{ .Values.ingressInternal.copilot.host | quote }} {{- end }} {{- end }} secretName: {{ .Values.ingressInternal.tls.secretName }} {{- end }} rules: {{- if $appActive }} - host: {{ .Values.ingressInternal.app.host | quote }} http: paths: {{- if and $realtimeActive (eq .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }} {{- range .Values.ingressInternal.realtime.paths }} - path: {{ .path }} pathType: {{ .pathType }} backend: service: name: {{ include "sim.fullname" $ }}-realtime port: number: {{ $.Values.realtime.service.port }} {{- end }} {{- end }} {{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} {{- range .Values.ingressInternal.copilot.paths }} - path: {{ .path }} pathType: {{ .pathType }} backend: service: name: {{ include "sim.fullname" $ }}-copilot port: number: {{ $.Values.copilot.server.service.port }} {{- end }} {{- end }} {{- range .Values.ingressInternal.app.paths }} - path: {{ .path }} pathType: {{ .pathType }} backend: service: name: {{ include "sim.fullname" $ }}-app port: number: {{ $.Values.app.service.port }} {{- end }} {{- end }} {{- if $realtimeHasOwnRule }} - host: {{ .Values.ingressInternal.realtime.host | quote }} http: paths: {{- range .Values.ingressInternal.realtime.paths }} - path: {{ .path }} pathType: {{ .pathType }} backend: service: name: {{ include "sim.fullname" $ }}-realtime port: number: {{ $.Values.realtime.service.port }} {{- end }} {{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }} {{- range .Values.ingressInternal.copilot.paths }} - path: {{ .path }} pathType: {{ .pathType }} backend: service: name: {{ include "sim.fullname" $ }}-copilot port: number: {{ $.Values.copilot.server.service.port }} {{- end }} {{- end }} {{- end }} {{- if $hasCopilotIngress }} {{- $copilotServed := false }} {{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} {{- $copilotServed = true }} {{- end }} {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }} {{- $copilotServed = true }} {{- end }} {{- if not $copilotServed }} - host: {{ .Values.ingressInternal.copilot.host | quote }} http: paths: {{- range .Values.ingressInternal.copilot.paths }} - path: {{ .path }} pathType: {{ .pathType }} backend: service: name: {{ include "sim.fullname" $ }}-copilot port: number: {{ $.Values.copilot.server.service.port }} {{- end }} {{- end }} {{- end }} {{- end }}