From 14edf097a3c067b8fad75f1b0d3890636649f358 Mon Sep 17 00:00:00 2001 From: Campbell Pool Date: Tue, 24 Mar 2026 15:04:39 -0700 Subject: [PATCH 1/4] feat: add redis.deployLocal toggle and HPA enhancements redis.deployLocal (default: true): skip in-cluster Redis when using external Redis/ElastiCache. Set to false to disable. HPA: add customMetrics, selectPolicy, and configurable policies list. customMetrics allows arbitrary HPA metric types alongside CPU/memory. selectPolicy controls Max/Min/Disabled per direction. policies overrides replace the default Pods+Percent policies. All backward-compatible with existing defaults. --- .../templates/gateway/hpa.yaml | 19 +++++++++++++++++++ .../templates/redis/deployment.yaml | 2 +- .../templates/redis/service.yaml | 2 +- charts/portkey-gateway/values.yaml | 17 +++++++++++++++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/charts/portkey-gateway/templates/gateway/hpa.yaml b/charts/portkey-gateway/templates/gateway/hpa.yaml index 5d95286..394155c 100644 --- a/charts/portkey-gateway/templates/gateway/hpa.yaml +++ b/charts/portkey-gateway/templates/gateway/hpa.yaml @@ -29,9 +29,19 @@ spec: type: Utilization averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} + {{- with .Values.autoscaling.customMetrics }} + {{- toYaml . | nindent 4 }} + {{- end }} behavior: scaleUp: stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleUp.stabilizationWindowSeconds | default 0 }} + {{- if .Values.autoscaling.behavior.scaleUp.selectPolicy }} + selectPolicy: {{ .Values.autoscaling.behavior.scaleUp.selectPolicy }} + {{- end }} + {{- if .Values.autoscaling.behavior.scaleUp.policies }} + policies: + {{- toYaml .Values.autoscaling.behavior.scaleUp.policies | nindent 8 }} + {{- else }} policies: - type: Pods value: {{ .Values.autoscaling.behavior.scaleUp.podScaleUpValue | default 4 }} @@ -39,10 +49,19 @@ spec: - type: Percent value: {{ .Values.autoscaling.behavior.scaleUp.percentScaleUpValue | default 100 }} periodSeconds: {{ .Values.autoscaling.behavior.scaleUp.periodSeconds | default 15 }} + {{- end }} scaleDown: stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleDown.stabilizationWindowSeconds | default 300 }} + {{- if .Values.autoscaling.behavior.scaleDown.selectPolicy }} + selectPolicy: {{ .Values.autoscaling.behavior.scaleDown.selectPolicy }} + {{- end }} + {{- if .Values.autoscaling.behavior.scaleDown.policies }} + policies: + {{- toYaml .Values.autoscaling.behavior.scaleDown.policies | nindent 8 }} + {{- else }} policies: - type: Pods value: {{ .Values.autoscaling.behavior.scaleDown.podScaleDownValue | default 1 }} periodSeconds: {{ .Values.autoscaling.behavior.scaleDown.periodSeconds | default 60 }} + {{- end }} {{- end }} diff --git a/charts/portkey-gateway/templates/redis/deployment.yaml b/charts/portkey-gateway/templates/redis/deployment.yaml index 46e7c02..1f5c89a 100644 --- a/charts/portkey-gateway/templates/redis/deployment.yaml +++ b/charts/portkey-gateway/templates/redis/deployment.yaml @@ -1,4 +1,4 @@ -{{- if eq .Values.environment.data.CACHE_STORE "redis" }} +{{- if and (eq .Values.environment.data.CACHE_STORE "redis") (ne (.Values.redis.deployLocal | toString) "false") }} apiVersion: apps/v1 kind: Deployment metadata: diff --git a/charts/portkey-gateway/templates/redis/service.yaml b/charts/portkey-gateway/templates/redis/service.yaml index 9177991..619dd46 100644 --- a/charts/portkey-gateway/templates/redis/service.yaml +++ b/charts/portkey-gateway/templates/redis/service.yaml @@ -1,4 +1,4 @@ -{{- if eq .Values.environment.data.CACHE_STORE "redis" }} +{{- if and (eq .Values.environment.data.CACHE_STORE "redis") (ne (.Values.redis.deployLocal | toString) "false") }} apiVersion: v1 kind: Service metadata: diff --git a/charts/portkey-gateway/values.yaml b/charts/portkey-gateway/values.yaml index f489504..d4b7506 100644 --- a/charts/portkey-gateway/values.yaml +++ b/charts/portkey-gateway/values.yaml @@ -238,16 +238,27 @@ autoscaling: maxReplicas: 20 targetCPUUtilizationPercentage: 60 targetMemoryUtilizationPercentage: 60 + # customMetrics: [] behavior: scaleUp: stabilizationWindowSeconds: 0 + # selectPolicy: Max podScaleUpValue: 2 percentScaleUpValue: 100 periodSeconds: 2 + # policies: + # - type: Pods + # value: 4 + # periodSeconds: 15 scaleDown: stabilizationWindowSeconds: 300 + # selectPolicy: Min podScaleDownValue: 1 periodSeconds: 60 + # policies: + # - type: Pods + # value: 1 + # periodSeconds: 60 # Additional volumes on the output Deployment definition. volumes: [] @@ -400,11 +411,13 @@ dataservice: # Redis-specific configuration section redis: - name: "redis" - serviceType: NodePort + name: "redis" + serviceType: NodePort servicePort: 6379 containerPort: 6379 resources: {} + # Set to false to skip in-cluster Redis when using external Redis/ElastiCache + deployLocal: true # MinIO configuration section minio: From 1a5e213dc42d71ce779bbf3b005423d69a150734 Mon Sep 17 00:00:00 2001 From: Campbell Pool Date: Wed, 25 Mar 2026 13:02:28 -0700 Subject: [PATCH 2/4] Update charts/portkey-gateway/values.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- charts/portkey-gateway/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/portkey-gateway/values.yaml b/charts/portkey-gateway/values.yaml index d4b7506..7e6eba5 100644 --- a/charts/portkey-gateway/values.yaml +++ b/charts/portkey-gateway/values.yaml @@ -248,8 +248,8 @@ autoscaling: periodSeconds: 2 # policies: # - type: Pods - # value: 4 - # periodSeconds: 15 + # value: 2 + # periodSeconds: 2 scaleDown: stabilizationWindowSeconds: 300 # selectPolicy: Min From 0bc7953e377efbe3632974aa11006561003b0722 Mon Sep 17 00:00:00 2001 From: Campbell Pool Date: Wed, 25 Mar 2026 13:02:52 -0700 Subject: [PATCH 3/4] Update charts/portkey-gateway/values.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- charts/portkey-gateway/values.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/portkey-gateway/values.yaml b/charts/portkey-gateway/values.yaml index 7e6eba5..743a60c 100644 --- a/charts/portkey-gateway/values.yaml +++ b/charts/portkey-gateway/values.yaml @@ -416,7 +416,10 @@ redis: servicePort: 6379 containerPort: 6379 resources: {} - # Set to false to skip in-cluster Redis when using external Redis/ElastiCache + # Set to false to skip deploying in-cluster Redis when using an external Redis/ElastiCache instance. + # When deployLocal is set to false, you MUST also configure Redis connection env vars + # (e.g. environment.data.REDIS_URL, or REDIS_HOST/REDIS_PORT) to point to your external Redis; + # otherwise the deployment will still try to connect to the default in-cluster service (redis://redis:6379). deployLocal: true # MinIO configuration section From 0886bc252869f39f0f71c36a19ecd7cb08f91a3d Mon Sep 17 00:00:00 2001 From: Campbell Pool Date: Thu, 26 Mar 2026 09:16:58 -0700 Subject: [PATCH 4/4] fix: simplify deployLocal guard to bare truthiness Replace toString/ne string comparison with simple truthiness check, consistent with every other boolean guard in the chart (dataservice.enabled, autoscaling.enabled, minio.enabled, etc.). --- charts/portkey-gateway/templates/redis/deployment.yaml | 2 +- charts/portkey-gateway/templates/redis/service.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/portkey-gateway/templates/redis/deployment.yaml b/charts/portkey-gateway/templates/redis/deployment.yaml index 1f5c89a..056d772 100644 --- a/charts/portkey-gateway/templates/redis/deployment.yaml +++ b/charts/portkey-gateway/templates/redis/deployment.yaml @@ -1,4 +1,4 @@ -{{- if and (eq .Values.environment.data.CACHE_STORE "redis") (ne (.Values.redis.deployLocal | toString) "false") }} +{{- if and (eq .Values.environment.data.CACHE_STORE "redis") .Values.redis.deployLocal }} apiVersion: apps/v1 kind: Deployment metadata: diff --git a/charts/portkey-gateway/templates/redis/service.yaml b/charts/portkey-gateway/templates/redis/service.yaml index 619dd46..0a66727 100644 --- a/charts/portkey-gateway/templates/redis/service.yaml +++ b/charts/portkey-gateway/templates/redis/service.yaml @@ -1,4 +1,4 @@ -{{- if and (eq .Values.environment.data.CACHE_STORE "redis") (ne (.Values.redis.deployLocal | toString) "false") }} +{{- if and (eq .Values.environment.data.CACHE_STORE "redis") .Values.redis.deployLocal }} apiVersion: v1 kind: Service metadata: