Skip to content

feat: add redis.deployLocal toggle and HPA enhancements#172

Open
camjay wants to merge 4 commits intoPortkey-AI:mainfrom
camjay:feat/redis-deploylocal-hpa
Open

feat: add redis.deployLocal toggle and HPA enhancements#172
camjay wants to merge 4 commits intoPortkey-AI:mainfrom
camjay:feat/redis-deploylocal-hpa

Conversation

@camjay
Copy link
Copy Markdown

@camjay camjay commented Mar 24, 2026

redis.deployLocal (default: true): Set to false to 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_URL in environment.data to point at the external instance.

HPA enhancements:

  • customMetrics: inject arbitrary HPA metric types alongside CPU/memory
  • selectPolicy: configure Max/Min/Disabled for scaleUp/scaleDown
  • policies: override default Pods+Percent policies with a custom list

All backward-compatible with existing defaults.

See also #173 which adds CI to validate chart templates on PRs.

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.
@camjay camjay force-pushed the feat/redis-deploylocal-hpa branch from 5fbb03a to 14edf09 Compare March 24, 2026 22:05
@camjay camjay marked this pull request as ready for review March 25, 2026 01:08
@sk-portkey sk-portkey requested a review from Copilot March 25, 2026 09:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (default true) to optionally skip rendering the in-cluster Redis Deployment/Service.
  • Extends the gateway HPA template to support customMetrics, selectPolicy, and custom policies.
  • Updates values.yaml with 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") }}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{{- 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) }}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") }}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{{- 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) }}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

camjay and others added 3 commits March 25, 2026 13:02
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 }}
Copy link
Copy Markdown
Contributor

@sk-portkey sk-portkey Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants