diff --git a/helm-chart/eoapi/templates/_helpers.tpl b/helm-chart/eoapi/templates/_helpers.tpl index 299c19b..b652e1e 100644 --- a/helm-chart/eoapi/templates/_helpers.tpl +++ b/helm-chart/eoapi/templates/_helpers.tpl @@ -159,11 +159,23 @@ so we use this helper function to check autoscaling rules {{- define "eoapi.validateAutoscaleRules" -}} {{- if and .Values.ingress.enabled (ne .Values.ingress.className "nginx") }} {{/* "requestRate" cannot be enabled for any service if not "nginx" so give feedback and fail */}} -{{- if (or (and .Values.raster.autoscaling.enabled (eq .Values.raster.autoscaling.type "requestRate")) (and .Values.stac.autoscaling.enabled (eq .Values.stac.autoscaling.type "requestRate")) (and .Values.vector.autoscaling.enabled (eq .Values.vector.autoscaling.type "requestRate")) ) }} +{{- $hasRequestRate := false }} +{{- range $serviceName, $service := .Values.externalServices }} + {{- if and $service.autoscaling.enabled (eq $service.autoscaling.type "requestRate") }} + {{- $hasRequestRate = true }} + {{- end }} +{{- end }} +{{- if $hasRequestRate }} {{- fail "When using an 'ingress.className' other than 'nginx' you cannot enable autoscaling by 'requestRate' at this time b/c it's solely an nginx metric" }} {{- end }} {{/* "both" cannot be enabled for any service if not "nginx" so give feedback and fail */}} -{{- if (or (and .Values.raster.autoscaling.enabled (eq .Values.raster.autoscaling.type "both")) (and .Values.stac.autoscaling.enabled (eq .Values.stac.autoscaling.type "both")) (and .Values.vector.autoscaling.enabled (eq .Values.vector.autoscaling.type "both")) ) }} +{{- $hasBoth := false }} +{{- range $serviceName, $service := .Values.externalServices }} + {{- if and $service.autoscaling.enabled (eq $service.autoscaling.type "both") }} + {{- $hasBoth = true }} + {{- end }} +{{- end }} +{{- if $hasBoth }} {{- fail "When using an 'ingress.className' other than 'nginx' you cannot enable autoscaling by 'both' at this time b/c 'requestRate' is solely an nginx metric" }} {{- end }} {{- end }} diff --git a/helm-chart/eoapi/tests/ingress_tests_nginx.yaml b/helm-chart/eoapi/tests/ingress_tests_nginx.yaml index bee00d0..fe63122 100644 --- a/helm-chart/eoapi/tests/ingress_tests_nginx.yaml +++ b/helm-chart/eoapi/tests/ingress_tests_nginx.yaml @@ -4,10 +4,10 @@ templates: tests: - it: "vector ingress defaults" set: - ingress.className: "nginx" - raster.enabled: false - stac.enabled: false - vector.enabled: true + externalServices.ingress.className: "nginx" + externalServices.raster.enabled: false + externalServices.stac.enabled: false + externalServices.vector.enabled: true asserts: - isKind: of: Ingress @@ -26,10 +26,10 @@ tests: value: "nginx" - it: "raster ingress defaults" set: - ingress.className: "nginx" - raster.enabled: true - stac.enabled: false - vector.enabled: false + externalServices.ingress.className: "nginx" + externalServices.raster.enabled: true + externalServices.stac.enabled: false + externalServices.vector.enabled: false asserts: - isKind: of: Ingress @@ -48,10 +48,10 @@ tests: value: "nginx" - it: "stac ingress defaults" set: - ingress.className: "nginx" - raster.enabled: false - stac.enabled: true - vector.enabled: false + externalServices.ingress.className: "nginx" + externalServices.raster.enabled: false + externalServices.stac.enabled: true + externalServices.vector.enabled: false asserts: - isKind: of: Ingress