2024-09-13 21:48:11 +03:00

50 lines
2.2 KiB
YAML

{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "codex.ingress.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "codex.labels" . | nindent 4 }}
annotations:
{{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.class }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
rules:
{{- range $hosts := $.Values.ingress.hosts }}
- host: {{ $hosts.host }}
http:
paths:
{{- range $paths := $hosts.paths }}
{{- range $replica_index := until (int $.Values.replica.count) }}
{{- with $ }}
{{- $service_replica_suffix := ternary "" (print "-" (add $replica_index .Values.statefulSet.ordinalsStart)) (and (eq (int .Values.replica.count) 1) .Values.statefulSet.prettify) }}
{{- $service_suffix := print "-" .Values.statefulSet.ordinalsStart -}}
{{- $service_name := print (include "codex.fullname" .) $service_replica_suffix (ternary ($service_suffix) "" (eq (toString .Values.service.prettify) "false")) "-service" }}
{{- $pod_replica_suffix := ternary "" (printf "-%0*s" (int $paths.leadingZeros | default 1) (toString (add $replica_index .Values.statefulSet.ordinalsStart))) (and (eq (int .Values.replica.count) 1) .Values.statefulSet.prettify) }}
{{- $pod_suffix := ternary (print "-" .Values.statefulSet.ordinalsStart) "" (eq (toString $paths.prettify) "false") }}
{{- $pod_uri := print (ternary (include "codex.fullname" .) $paths.podName (or (eq $paths.podName "") (eq $paths.podName nil))) $pod_replica_suffix $pod_suffix }}
{{- $path := print $paths.path (ternary "" "/" (eq $paths.path "/")) $pod_uri $paths.rewritePath }}
- path: {{ $path }}
pathType: {{ $paths.pathType }}
backend:
service:
name: {{ $service_name }}
port:
number: {{ .Values.service.api.port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}