Skip to content

Commit 980b03c

Browse files
feat(helm): add secretRef support for grafana-mcp
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 <ugax2kontomo0314@gmail.com>
1 parent 02f2956 commit 980b03c

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

helm/kagent/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ tools:
349349
grafana-mcp:
350350
grafana:
351351
url: "grafana.kagent:3000/api"
352-
apiKey: "-"
352+
serviceAccountToken: ""
353+
# apiKey: "" # Deprecated - use serviceAccountToken instead.
354+
# secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY)
353355
resources:
354356
requests:
355357
cpu: 100m

helm/tools/grafana-mcp/templates/deployment.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ spec:
4848
envFrom:
4949
- configMapRef:
5050
name: {{ include "grafana-mcp.fullname" . }}
51+
{{- if or .Values.grafana.secretRef .Values.grafana.serviceAccountToken .Values.grafana.apiKey }}
5152
- secretRef:
52-
name: {{ include "grafana-mcp.fullname" . }}
53+
name: {{ .Values.grafana.secretRef | default (include "grafana-mcp.fullname" .) | quote }}
54+
{{- end }}
5355
ports:
5456
- name: http
5557
containerPort: {{ .Values.service.port }}

helm/tools/grafana-mcp/templates/secret.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
{{- if or .Values.grafana.serviceAccountToken .Values.grafana.apiKey }}
12
apiVersion: v1
23
kind: Secret
34
metadata:
4-
name: {{ include "grafana-mcp.fullname" . }}
5+
name: {{ .Values.grafana.secretRef | default (include "grafana-mcp.fullname" .) | quote }}
56
namespace: {{ .Release.Namespace }}
67
labels:
78
{{- include "grafana-mcp.labels" . | nindent 4 }}
@@ -13,3 +14,4 @@ data:
1314
{{- if and .Values.grafana.apiKey (not .Values.grafana.serviceAccountToken) }}
1415
GRAFANA_API_KEY: {{ .Values.grafana.apiKey | b64enc }}
1516
{{- end }}
17+
{{- end }}

helm/tools/grafana-mcp/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ replicas: 1
33
grafana:
44
url: "grafana.kagent:3000/api"
55
serviceAccountToken: ""
6-
apiKey: "" # Deprecated - use serviceAccountToken instead.
6+
# apiKey: "" # Deprecated - use serviceAccountToken instead.
7+
# secretRef: "" # Name of Secret to reference (contains GRAFANA_SERVICE_ACCOUNT_TOKEN or GRAFANA_API_KEY)
78

89
image:
910
registry: mcp

0 commit comments

Comments
 (0)