diff --git a/charts/pubcode/templates/api/templates/ingress.yaml b/charts/pubcode/templates/api/templates/ingress.yaml index 339eea1..8fcd562 100644 --- a/charts/pubcode/templates/api/templates/ingress.yaml +++ b/charts/pubcode/templates/api/templates/ingress.yaml @@ -1,4 +1,9 @@ -{{- if and .Values.api.enabled .Values.api.route .Values.api.route.enabled }} +{{- $ing := .Values.api.ingress | default dict -}} +{{- if and (eq (len $ing) 0) .Values.api.route -}} +{{- $ing = .Values.api.route -}} +{{- end -}} + +{{- if and .Values.api.enabled $ing $ing.enabled }} {{- $svcName := include "api.fullname" . -}} {{- $defaultSvcPort := 80 -}} {{- if and .Values.api.service .Values.api.service.ports (gt (len .Values.api.service.ports) 0) -}} @@ -10,14 +15,40 @@ metadata: name: {{ $svcName }} labels: {{- include "api.labels" . | nindent 4 }} - {{- if .Values.api.route.annotations }} + {{- if $ing.annotations }} annotations: - {{- tpl (toYaml .Values.api.route.annotations) $ | nindent 4 }} + {{- tpl (toYaml $ing.annotations) $ | nindent 4 }} {{- end }} spec: - ingressClassName: {{ default "openshift-default" .Values.api.route.className }} + ingressClassName: {{ default "openshift-default" $ing.className }} rules: - - host: {{ tpl (default (printf "%s.%s" $svcName .Values.global.domain) (printf "%v" .Values.api.route.host)) $ | quote }} + {{- if and $ing.hosts (gt (len $ing.hosts) 0) }} + {{- range $h := $ing.hosts }} + - host: {{ tpl $h.host $ | quote }} + http: + paths: + {{- if and $h.paths (gt (len $h.paths) 0) }} + {{- range $p := $h.paths }} + - path: {{ default "/" $p.path | quote }} + pathType: {{ default "ImplementationSpecific" $p.pathType }} + backend: + service: + name: {{ $svcName }} + port: + number: {{ $defaultSvcPort }} + {{- end }} + {{- else }} + - path: "/" + pathType: ImplementationSpecific + backend: + service: + name: {{ $svcName }} + port: + number: {{ $defaultSvcPort }} + {{- end }} + {{- end }} + {{- else }} + - host: {{ tpl (default (printf "%s.%s" $svcName .Values.global.domain) (printf "%v" $ing.host)) $ | quote }} http: paths: - path: "/" @@ -27,4 +58,5 @@ spec: name: {{ $svcName }} port: number: {{ $defaultSvcPort }} + {{- end }} {{- end }} diff --git a/charts/pubcode/values.yaml b/charts/pubcode/values.yaml index 0722ad7..976e5fe 100644 --- a/charts/pubcode/values.yaml +++ b/charts/pubcode/values.yaml @@ -85,10 +85,23 @@ api: nodeSelector: { } tolerations: [ ] affinity: { } - route: + + ingress: enabled: true - host: "{{ .Release.Name }}-api.{{ .Values.global.domain }}" - targetPort: http # look at line#164 refer to the name. + className: openshift-default + annotations: + haproxy.router.openshift.io/balance: "roundrobin" + route.openshift.io/termination: "edge" + haproxy.router.openshift.io/rate-limit-connections: "true" + haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp: "20" + haproxy.router.openshift.io/rate-limit-connections.rate-http: "50" + haproxy.router.openshift.io/rate-limit-connections.rate-tcp: "100" + haproxy.router.openshift.io/disable_cookies: "true" + hosts: + - host: "{{ .Release.Name }}-api.{{ .Values.global.domain }}" + paths: + - path: / + pathType: ImplementationSpecific podAnnotations: |- prometheus.io/scrape: "true" prometheus.io/port: "3000"