Skip to content

manifests: load REDIS_PASSWORD from Secret via secretKeyRef#372

Merged
volcano-sh-bot merged 3 commits into
volcano-sh:mainfrom
kubeboiii:fix/redis-password-secret-ref
Jun 3, 2026
Merged

manifests: load REDIS_PASSWORD from Secret via secretKeyRef#372
volcano-sh-bot merged 3 commits into
volcano-sh:mainfrom
kubeboiii:fix/redis-password-secret-ref

Conversation

@kubeboiii
Copy link
Copy Markdown
Contributor

@kubeboiii kubeboiii commented Jun 2, 2026

What type of PR is this?

Security fix for Helm chart credential handling.

What this PR does / why we need it:

The Helm chart embedded the Redis password directly in Deployment env value fields for workloadmanager and agentcube-router. Anyone with read access to Deployments in the namespace could read the credential from kubectl get deployment -o yaml.

This PR stores the password in a Kubernetes Secret and references it with secretKeyRef for REDIS_PASSWORD in both components. When redis.secretName is unset and redis.password is set, the chart creates a Secret named {release}-redis. When redis.secretName is set, the chart skips Secret creation and uses the provided Secret name and key. When neither is set, no Secret or REDIS_PASSWORD env is rendered (supports e2e and dev installs with REDIS_PASSWORD_REQUIRED=false).

No changes to application code. Components continue to read REDIS_PASSWORD from the environment.

Which issue(s) this PR fixes:
Fixes #368

Special notes for your reviewer:

  • Chart-only change under manifests/charts/base/ plus docs/getting-started.md.
  • Backward compatible: helm install --set redis.password=... still works; the value is written to a Secret instead of the Deployment manifest.
  • New values: redis.secretName, redis.secretKey (default key: password). Use either redis.password or redis.secretName, not both.
  • E2E installs that use --set redis.password="" with REDIS_PASSWORD_REQUIRED=false are unchanged in behavior.
  • Using --set redis.password still places the value in Helm release metadata. Production installs should prefer a pre-created Secret via redis.secretName (documented in getting-started).

Does this PR introduce a user-facing change?:
Yes. Helm installs now create or reference a Redis Secret for credentials instead of inlining the password in Deployment specs.

Redis credentials for workloadmanager and agentcube-router are loaded from a Kubernetes Secret via secretKeyRef instead of plain-text Deployment env values. Chart-managed Secret `{release}-redis` is created when `redis.secretName` is not set and `redis.password` is provided; use `redis.secretName` to supply your own Secret in production.

Copilot AI review requested due to automatic review settings June 2, 2026 06:53
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

@kubeboiii: The label(s) kind/security cannot be applied, because the repository doesn't have them.

Details

In response to this:

What type of PR is this?

/kind security

What this PR does / why we need it:

The Helm chart embedded the Redis password directly in Deployment env value fields for workloadmanager and agentcube-router. Anyone with read access to Deployments in the namespace could read the credential from kubectl get deployment -o yaml.

This PR stores the password in a Kubernetes Secret and references it with secretKeyRef for REDIS_PASSWORD in both components. When redis.existingSecret is unset, the chart creates a Secret named {release}-redis from redis.password. When redis.existingSecret is set, the chart skips Secret creation and uses the provided Secret name and key.

No changes to application code. Components continue to read REDIS_PASSWORD from the environment.

Which issue(s) this PR fixes:
Fixes #368

Special notes for your reviewer:

  • Chart-only change under manifests/charts/base/ plus docs/getting-started.md.
  • Backward compatible: helm install --set redis.password=... still works; the value is written to a Secret instead of the Deployment manifest.
  • New values: redis.existingSecret, redis.existingSecretPasswordKey (default key: password).
  • E2E installs that use --set redis.password="" with REDIS_PASSWORD_REQUIRED=false are unchanged in behavior.
  • Using --set redis.password still places the value in Helm release metadata. Production installs should prefer a pre-created Secret via redis.existingSecret (documented in getting-started).

Does this PR introduce a user-facing change?:
Yes. Helm installs now create or reference a Redis Secret for credentials instead of inlining the password in Deployment specs.

Redis credentials for workloadmanager and agentcube-router are loaded from a Kubernetes Secret via secretKeyRef instead of plain-text Deployment env values. Chart-managed Secret `{release}-redis` is created when `redis.existingSecret` is not set; use `redis.existingSecret` to supply your own Secret in production.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Welcome @kubeboiii! It looks like this is your first PR to volcano-sh/agentcube 🎉

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR moves Redis password configuration in the Helm chart from plain-text env values to Kubernetes Secrets with support for referencing a pre-existing Secret, and updates docs accordingly.

Changes:

  • Inject REDIS_PASSWORD via secretKeyRef instead of a plain value.
  • Add an optional chart-managed Redis Secret and helpers to derive Secret name/key.
  • Document chart-managed vs. existing Secret setup in getting started guide.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
manifests/charts/base/values.yaml Adds values for using an existing Redis Secret and configuring the password key name.
manifests/charts/base/templates/workloadmanager.yaml Switches REDIS_PASSWORD to valueFrom.secretKeyRef.
manifests/charts/base/templates/agentcube-router.yaml Switches REDIS_PASSWORD to valueFrom.secretKeyRef.
manifests/charts/base/templates/redis-secret.yaml Adds chart-managed Redis password Secret when existingSecret is unset.
manifests/charts/base/templates/_helpers.tpl Adds helper templates for Redis Secret name and password key.
docs/getting-started.md Documents new Secret-based configuration and new Helm values.

@@ -0,0 +1,13 @@
{{- if not .Values.redis.existingSecret }}
Comment on lines +11 to +13
stringData:
{{ include "agentcube.redis.passwordKey" . }}: {{ .Values.redis.password | quote }}
{{- end }}
Comment on lines +4 to +10
{{- define "agentcube.redis.secretName" -}}
{{- if .Values.redis.existingSecret }}
{{- .Values.redis.existingSecret }}
{{- else }}
{{- printf "%s-redis" .Release.Name }}
{{- end }}
{{- end }}
Comment on lines +64 to +67
valueFrom:
secretKeyRef:
name: {{ include "agentcube.redis.secretName" . }}
key: {{ include "agentcube.redis.passwordKey" . }}
Comment thread docs/getting-started.md Outdated
--set router.serviceAccountName="agentcube-router"
```

The Redis password is stored in a Kubernetes Secret and injected via `secretKeyRef` (not plain text in Deployment manifests). With the command above, Helm creates a chart-managed Secret from `redis.password`.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves security by injecting the Redis password via a Kubernetes Secret using secretKeyRef instead of plain text in the deployment manifests. It adds support for both chart-managed secrets and referencing an existing external secret, updating the documentation, helper templates, and deployment configurations accordingly. The review feedback suggests avoiding the creation of an empty Secret when no password is provided, and conditionally injecting the REDIS_PASSWORD environment variable in the router and workload manager deployments to prevent failures in environments where a password is not required.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@@ -0,0 +1,13 @@
{{- if not .Values.redis.existingSecret }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To avoid creating an empty Secret when no Redis password is provided (e.g., in local development or test environments where REDIS_PASSWORD_REQUIRED=false is used), we should only create this Secret if redis.password is actually set.

{{- if and (not .Values.redis.existingSecret) .Values.redis.password }}

Comment on lines +67 to +71
- name: REDIS_PASSWORD
value: {{ .Values.redis.password | quote }}
valueFrom:
secretKeyRef:
name: {{ include "agentcube.redis.secretName" . }}
key: {{ include "agentcube.redis.passwordKey" . }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To prevent the deployment from failing when no Redis password is provided (and thus no Secret is created), we should conditionally inject the REDIS_PASSWORD environment variable only when either redis.password or redis.existingSecret is configured.

            {{- if or .Values.redis.password .Values.redis.existingSecret }}
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ include "agentcube.redis.secretName" . }}
                  key: {{ include "agentcube.redis.passwordKey" . }}
            {{- end }}

Comment on lines +63 to +67
- name: REDIS_PASSWORD
value: {{ .Values.redis.password | quote }}
valueFrom:
secretKeyRef:
name: {{ include "agentcube.redis.secretName" . }}
key: {{ include "agentcube.redis.passwordKey" . }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To prevent the deployment from failing when no Redis password is provided (and thus no Secret is created), we should conditionally inject the REDIS_PASSWORD environment variable only when either redis.password or redis.existingSecret is configured.

            {{- if or .Values.redis.password .Values.redis.existingSecret }}
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ include "agentcube.redis.secretName" . }}
                  key: {{ include "agentcube.redis.passwordKey" . }}
            {{- end }}

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 2, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.98%. Comparing base (524e55e) to head (d1179ed).
⚠️ Report is 110 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #372       +/-   ##
===========================================
+ Coverage   47.57%   57.98%   +10.41%     
===========================================
  Files          30       34        +4     
  Lines        2819     3180      +361     
===========================================
+ Hits         1341     1844      +503     
+ Misses       1338     1151      -187     
- Partials      140      185       +45     
Flag Coverage Δ
unittests 57.98% <ø> (+10.41%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Store Redis credentials in a Kubernetes Secret and inject them with
secretKeyRef in workloadmanager and agentcube-router Deployments.
Add redis.existingSecret for production installs.
Skip Secret and REDIS_PASSWORD env when no password is configured.

Signed-off-by: Himanshu <144804569+kubeboiii@users.noreply.github.com>
Comment thread manifests/charts/base/values.yaml Outdated
# For production, prefer creating a Secret yourself and set existingSecret instead.
password: ""
# Name of an existing Secret containing the Redis password (skips chart Secret creation).
existingSecret: ""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why call existingSecret?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to redis.secretName — clearer than existingSecret. When set, the chart does not create {release}-redis and both Deployments use that Secret via secretKeyRef.

Comment thread manifests/charts/base/values.yaml Outdated
# Name of an existing Secret containing the Redis password (skips chart Secret creation).
existingSecret: ""
# Key within existingSecret or chart-managed Secret (default: password).
existingSecretPasswordKey: "password"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to redis.secretKey (default password). Used directly in templates with | default "password" instead of a helper.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not a must

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed _helpers.tpl and inlined the logic in the three templates as suggested.

{{/*
Key within the Redis Secret that holds the password.
*/}}
{{- define "agentcube.redis.passwordKey" -}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think redefining another var makes it harder to understand

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped the passwordKey helper; templates now use .Values.redis.secretKey | default "password" directly.

kubeboiii added 2 commits June 2, 2026 18:33
Rename redis.existingSecret to redis.secretName and
redis.existingSecretPasswordKey to redis.secretKey. Inline
secret name/key in templates and remove _helpers.tpl.

Signed-off-by: Himanshu <144804569+kubeboiii@users.noreply.github.com>
Document mutual exclusivity of redis.password vs redis.secretName,
add upgrade note, and remove invalid router.rbac.create from examples.

Signed-off-by: Himanshu <144804569+kubeboiii@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 13:17
@kubeboiii
Copy link
Copy Markdown
Contributor Author

Thanks @hzxuzhonghu for the review — addressed in the latest commits:

  • Renamed redis.existingSecret / redis.existingSecretPasswordKey to redis.secretName and redis.secretKey.
  • Removed templates/_helpers.tpl and inlined the Secret name/key logic in redis-secret.yaml, workloadmanager.yaml, and agentcube-router.yaml.
  • Behavior for Redis password stored in plain text #368 is unchanged: no plain-text REDIS_PASSWORD in Deployment manifests; credentials come from a Secret via secretKeyRef.

Also added a short note in values.yaml and getting-started (mutual exclusivity of password vs secretName, upgrade rolling restart).

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment on lines +1 to +13
{{- if and (not .Values.redis.secretName) .Values.redis.password }}
apiVersion: v1
kind: Secret
metadata:
name: {{ printf "%s-redis" .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: agentcube
app.kubernetes.io/instance: {{ .Release.Name }}
type: Opaque
stringData:
{{ .Values.redis.secretKey | default "password" }}: {{ .Values.redis.password | quote }}
{{- end }}
Comment on lines +63 to +69
{{- if or .Values.redis.password .Values.redis.secretName }}
- name: REDIS_PASSWORD
value: {{ .Values.redis.password | quote }}
valueFrom:
secretKeyRef:
name: {{ .Values.redis.secretName | default (printf "%s-redis" .Release.Name) | quote }}
key: {{ .Values.redis.secretKey | default "password" | quote }}
{{- end }}
Comment thread docs/getting-started.md
Comment on lines 66 to 69
--create-namespace \
--set redis.addr="redis.agentcube.svc.cluster.local:6379" \
--set redis.password="''''" \
--set router.rbac.create=true \
--set router.serviceAccountName="agentcube-router"
Comment thread docs/getting-started.md
Comment on lines +80 to +85
helm install agentcube ./manifests/charts/base \
--namespace agentcube \
--create-namespace \
--set redis.addr="redis.agentcube.svc.cluster.local:6379" \
--set redis.secretName="agentcube-redis" \
--set router.serviceAccountName="agentcube-router"
Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

I think we can also update the e2e with password

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot merged commit 16e8330 into volcano-sh:main Jun 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redis password stored in plain text

5 participants