feat(helm): add secretRef support for grafana-mcp#1211
feat(helm): add secretRef support for grafana-mcp#1211EItanya merged 1 commit intokagent-dev:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for referencing existing Secrets in the grafana-mcp Helm chart, improving security by allowing users to manage authentication credentials externally rather than exposing them in values files or CLI arguments.
Changes:
- Added
secretRefconfiguration option to allow referencing pre-existing Secrets containing Grafana credentials - Modified Secret template to conditionally create Secrets only when credentials are directly provided
- Updated deployment template to use either the referenced Secret or the chart-generated Secret name
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| helm/tools/grafana-mcp/values.yaml | Added commented secretRef field and commented out deprecated apiKey field |
| helm/tools/grafana-mcp/templates/secret.yaml | Added conditional creation of Secret and support for custom Secret names via secretRef |
| helm/tools/grafana-mcp/templates/deployment.yaml | Added conditional Secret reference in deployment based on credential configuration |
| helm/kagent/values.yaml | Updated default values to use serviceAccountToken instead of apiKey and added secretRef option |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| kind: Secret | ||
| metadata: | ||
| name: {{ include "grafana-mcp.fullname" . }} | ||
| name: {{ .Values.grafana.secretRef | default (include "grafana-mcp.fullname" .) | quote }} |
There was a problem hiding this comment.
When secretRef is provided, this template creates a Secret with that name, which could overwrite an existing Secret the user intended to reference. The Secret should only be created with the chart-generated name. If secretRef is specified, this Secret resource should not be created at all.
There was a problem hiding this comment.
secretRef is used in deployment to refer this secret. If secretRef is specified with serviceAccountToken or apiKey, which is unintended misuse, deployment will refer unexisting Secret. To prevent such a trouble, I also setsecretRef to Secret resource.
There was a problem hiding this comment.
So I approved, but I actually do agree with this comment. I agree that the secret should be optionally created, but we need to make sure that the name of this is consistent, this line should be reverted
There was a problem hiding this comment.
I was worried too much about the pattern of setting together the secretRef and either the serviceAccountToken or the apiKey . However, this is a misuse and does not need to be cared for so much.
I simply kept a consistent secret name.
|
Hi, just a gentle reminder about this PR. |
EItanya
left a comment
There was a problem hiding this comment.
So I actually read through the template changes and I think they need a couple of minor changes
| kind: Secret | ||
| metadata: | ||
| name: {{ include "grafana-mcp.fullname" . }} | ||
| name: {{ .Values.grafana.secretRef | default (include "grafana-mcp.fullname" .) | quote }} |
There was a problem hiding this comment.
So I approved, but I actually do agree with this comment. I agree that the secret should be optionally created, but we need to make sure that the name of this is consistent, this line should be reverted
| envFrom: | ||
| - configMapRef: | ||
| name: {{ include "grafana-mcp.fullname" . }} | ||
| {{- if or .Values.grafana.secretRef .Values.grafana.serviceAccountToken .Values.grafana.apiKey }} |
There was a problem hiding this comment.
Isn't this always true? If one of these isn't true than the config is invalid anyway?
There was a problem hiding this comment.
Yes, you are right.
There should always be a secret with some credentials.
This if statement is unnecessary.
980b03c to
3c0aca9
Compare
|
@EItanya |
|
i've rerun the tests just in case, but i think the failure was real |
Enable to reference an existing Secret for grafana-mcp authentication instead of having the chart create new one. This improves security because it enables not to expose sensitive credentials in values file or `--set` option of helm cli or argocd application. - Added `secretRef` field to both `helm/kagent/values.yaml` and `helm/tools/grafana-mcp/values.yaml` to allow users to specify an existing Secret name containing `GRAFANA_SERVICE_ACCOUNT_TOKEN` or `GRAFANA_API_KEY`. - Modified `helm/tools/grafana-mcp/templates/secret.yaml` to create a Secret only when `secretRef` is not provided. - Updated `helm/tools/grafana-mcp/templates/deployment.yaml` to reference the Secret specified by `secretRef` if provided, otherwise fall back to the chart-generated Secret name. Signed-off-by: TOMOFUMI-KONDO <ugax2kontomo0314@gmail.com>
3c0aca9 to
49f4fed
Compare
The issue was that the Secret referenced from Deployment does not exist. |
Hello. Thank you for all your mantaining this project.
Overview
Add the ability to reference an existing Secret for grafana-mcp authentication instead of having the chart create new one.
This update improves security because it enables not to expose sensitive credentials in values file or
--setoption of helm cli or argocd application.Changes
Add secretRef option to values.yaml
Added
secretReffield to bothhelm/kagent/values.yamlandhelm/tools/grafana-mcp/values.yamlto allow users to specify an existing Secret name containingGRAFANA_SERVICE_ACCOUNT_TOKENorGRAFANA_API_KEY.Conditionally create Secret and refer it from deployment
Modified
helm/tools/grafana-mcp/templates/secret.yamlto create a Secret only whenserviceAccountTokenorapiKeyis provided. This prevents creating an empty Secret when usingsecretRef.And also updated
helm/tools/grafana-mcp/templates/deployment.yamlto reference the Secret specified bysecretRefif provided, otherwise fall back to the chart-generated Secret name.Behavior change Matrix
GRAFANA_SERVICE_ACCOUNT_TOKENGRAFANA_API_KEYenvFrom.secretRefsecretRefis referenced from DeploymentRemarks
modelconfig-secretpattern.