-
Notifications
You must be signed in to change notification settings - Fork 392
feat(helm): add secretRef support for grafana-mcp #1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(helm): add secretRef support for grafana-mcp #1211
Conversation
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 `--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 `serviceAccountToken` or `apiKey` is provided. This prevents creating an empty Secret when using `secretRef`. And also 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. If no `apiKey` and `serviceAccountToken` are passed, and no `secretRef` is specified, Secret for grafana-mcp-server is not created and reference with it in deployment disappers to prevent deployment creation failure. Signed-off-by: TOMOFUMI-KONDO <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| url: "grafana.kagent:3000/api" | ||
| serviceAccountToken: "" | ||
| apiKey: "" # Deprecated - use serviceAccountToken instead. | ||
| # apiKey: "" # Deprecated - use serviceAccountToken instead. |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The apiKey field should remain uncommented with an empty default value for backward compatibility, similar to serviceAccountToken on line 5. Users relying on this field in their existing configurations may experience breaking changes if it's only available as a comment.
| # apiKey: "" # Deprecated - use serviceAccountToken instead. | |
| apiKey: "" # Deprecated - use serviceAccountToken instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I follow the pattern of modelconfig-secret, e.x. Values.providers.openAI.apiKey.
| serviceAccountToken: "" | ||
| apiKey: "" # Deprecated - use serviceAccountToken instead. | ||
| # apiKey: "" # Deprecated - use serviceAccountToken instead. | ||
| # secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY) |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The secretRef field should be uncommented with an empty default value to make it discoverable as a supported configuration option, consistent with how serviceAccountToken is defined on line 5.
| # secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY) | |
| secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I follow the pattern of modelconfig-secret, e.x. Values.providers.openAI.apiKey.
| kind: Secret | ||
| metadata: | ||
| name: {{ include "grafana-mcp.fullname" . }} | ||
| name: {{ .Values.grafana.secretRef | default (include "grafana-mcp.fullname" .) | quote }} |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| # apiKey: "" # Deprecated - use serviceAccountToken instead. | ||
| # secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY) |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields should be uncommented with empty default values for consistency with serviceAccountToken on line 352 and to maintain backward compatibility for apiKey.
| # apiKey: "" # Deprecated - use serviceAccountToken instead. | |
| # secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY) | |
| apiKey: "" # Deprecated - use serviceAccountToken instead. | |
| secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I follow the pattern of modelconfig-secret, e.x. Values.providers.openAI.apiKey.
|
Hi, just a gentle reminder about this PR. |
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.If no
apiKeyandserviceAccountTokenare passed, and nosecretRefis specified, Secret for grafana-mcp-server is not created and reference with it in deployment disappers to prevent deployment creation failure.Behavior change Matrix
apiKey="",serviceAccountToken="") Empty Secret will be createdapiKey="",serviceAccountToken="",secretRef="") Secret not created andenvFrom.secretRefin deployment removedGRAFANA_SERVICE_ACCOUNT_TOKENGRAFANA_API_KEYenvFrom.secretRefGRAFANA_SERVICE_ACCOUNT_TOKENcreated, and secret name changes to the specified oneRemarks
modelconfig-secretpattern.