feat: add redis.deployLocal toggle and HPA enhancements#172
feat: add redis.deployLocal toggle and HPA enhancements#172camjay wants to merge 4 commits intoPortkey-AI:mainfrom
Conversation
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.
5fbb03a to
14edf09
Compare
There was a problem hiding this comment.
Pull request overview
Adds Helm chart toggles and template enhancements to support external Redis usage and more configurable HPA behavior, while keeping existing defaults working.
Changes:
- Introduces
redis.deployLocal(defaulttrue) to optionally skip rendering the in-cluster Redis Deployment/Service. - Extends the gateway HPA template to support
customMetrics,selectPolicy, and custompolicies. - Updates
values.yamlwith commented examples for the new HPA fields and adds the new Redis value.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
charts/portkey-gateway/values.yaml |
Adds redis.deployLocal value and documents new HPA customization knobs via comments/examples. |
charts/portkey-gateway/templates/redis/service.yaml |
Gates Redis Service creation on redis.deployLocal in addition to CACHE_STORE=redis. |
charts/portkey-gateway/templates/redis/deployment.yaml |
Gates Redis Deployment creation on redis.deployLocal in addition to CACHE_STORE=redis. |
charts/portkey-gateway/templates/gateway/hpa.yaml |
Adds support for injecting custom metrics and overriding HPA behavior policies/selectPolicy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -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") }} | |||
There was a problem hiding this comment.
The deployLocal gate is implemented via a string comparison (ne (.Values.redis.deployLocal | toString) "false"). This is harder to reason about than a boolean default and can behave unexpectedly if the value is set to a non-bool (e.g., 0, "no", etc.). Consider using a boolean-safe pattern like (.Values.redis.deployLocal | default true) and negating it, so the intent and type expectations are clear.
| {{- 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 | default true) }} |
There was a problem hiding this comment.
Simplified to bare truthiness (.Values.redis.deployLocal) in 0886bc2 — consistent with every other boolean in the chart.
| default true doesn't work here because Helm's default treats false as empty/falsy, so false | default true evaluates to true — making it impossible to disable local redis via deployLocal: false.
| @@ -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") }} | |||
There was a problem hiding this comment.
The deployLocal gate is implemented via a string comparison (ne (.Values.redis.deployLocal | toString) "false"). This is harder to reason about than a boolean default and can behave unexpectedly if the value is set to a non-bool. Consider using a boolean-safe pattern like (.Values.redis.deployLocal | default true) and negating it so the template logic stays type-consistent.
| {{- 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 | default true) }} |
There was a problem hiding this comment.
Simplified to bare truthiness (.Values.redis.deployLocal) in 0886bc2 — consistent with every other boolean in the chart.
| default true doesn't work here because Helm's default treats false as empty/falsy, so false | default true evaluates to true — making it impossible to disable local redis via deployLocal: false.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.).
| @@ -1,4 +1,4 @@ | |||
| {{- if eq .Values.environment.data.CACHE_STORE "redis" }} | |||
| {{- if and (eq .Values.environment.data.CACHE_STORE "redis") .Values.redis.deployLocal }} | |||
There was a problem hiding this comment.
@camjay Thanks for putting this together — the HPA enhancements (customMetrics, selectPolicy, configurable policies) look useful and I'm happy to take those in.
For the redis.deployLocal part, I'd like to hold off. Today the chart already gates the Redis Deployment/Service on CACHE_STORE = "redis" — so users pointing at external Redis can control this through the existing environment config. Adding deployLocal as a second flag means operators now need to reason about two knobs (CACHE_STORE and deployLocal) to control one outcome, which adds friction without a clear benefit over what's already there.
I realize there's a gap if someone wants CACHE_STORE = "redis" (to tell the app to use Redis) but doesn't want the in-cluster Redis deployed. If that's the use case you're hitting, I'd be interested to hear more — we could look at a cleaner way to handle it. But as a general-purpose toggle, I think it overlaps too much with the existing condition.
Would you be open to splitting out the HPA changes into their own PR so we can move those forward?
redis.deployLocal (default:
true): Set tofalseto skip in-cluster Redis Deployment and Service when using external Redis (ElastiCache, Azure Cache, etc.). Uses bare truthiness consistent with every other boolean guard in the chart (dataservice.enabled,autoscaling.enabled, etc.).When disabling local Redis, set
REDIS_URLinenvironment.datato point at the external instance.HPA enhancements:
customMetrics: inject arbitrary HPA metric types alongside CPU/memoryselectPolicy: configure Max/Min/Disabled for scaleUp/scaleDownpolicies: override default Pods+Percent policies with a custom listAll backward-compatible with existing defaults.
See also #173 which adds CI to validate chart templates on PRs.