Skip to content

Commit 9fed818

Browse files
committed
add option to use a grafana api key from helm cli
Signed-off-by: AvivGuiser <[email protected]>
1 parent cd2b0e1 commit 9fed818

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

charts/grafana-mcp/README.md.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ helm repo add grafana https://grafana.github.io/helm-charts
2121
To install the chart with the release name `my-release`:
2222

2323
```console
24-
helm install my-release grafana/grafana-mcp
24+
helm install --set grafana.apiKey=<Grafana_ApiKey> my-release grafana/grafana-mcp
2525
```
2626

2727

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# Leave this file empty to ensure that CI runs builds against the default configuration in values.yaml.
1+
grafana:
2+
apiKey: "test"

charts/grafana-mcp/templates/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ spec:
9292
- name: GRAFANA_API_KEY
9393
valueFrom:
9494
secretKeyRef:
95+
{{- if .Values.grafana.apiKey }}
96+
name: {{ include "grafana-mcp.fullname" . }}
97+
key: api-key
98+
{{- else }}
9599
name: {{ .Values.grafana.apiKeySecret.name }}
96100
key: {{ .Values.grafana.apiKeySecret.key }}
101+
{{- end }}
97102
{{- range $key, $value := .Values.env }}
98103
- name: {{ $key | quote }}
99104
value: {{ $value | quote }}
@@ -107,6 +112,7 @@ spec:
107112
envFrom:
108113
{{- toYaml . | nindent 12 }}
109114
{{- end }}
115+
{{- if or (.Values.debug) (.Values.disabledCategories) (.Values.extraArgs) }}
110116
args:
111117
{{- if .Values.debug }}
112118
- -debug
@@ -117,6 +123,12 @@ spec:
117123
{{- with .Values.extraArgs }}
118124
{{- toYaml . | nindent 12 }}
119125
{{- end }}
126+
{{- else -}}
127+
{{- with .Values.extraArgs }}
128+
args:
129+
{{- toYaml . | nindent 12 }}
130+
{{- end }}
131+
{{- end }}
120132
{{- with .Values.lifecycle }}
121133
lifecycle:
122134
{{- toYaml . | nindent 12 }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.grafana.apiKey }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ include "grafana-mcp.fullname" . }}
6+
namespace: {{ include "grafana-mcp.namespace" . }}
7+
labels:
8+
{{- include "grafana-mcp.labels" . | nindent 4 }}
9+
{{- with .Values.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
type: Opaque
14+
stringData:
15+
api-key: {{ .Values.grafana.apiKey }}
16+
{{- end }}

charts/grafana-mcp/values.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ imagePullSecrets: []
2626
grafana:
2727
# -- Grafana URL (should point to the main Grafana service)
2828
url: "http://grafana:3000"
29+
# -- Grafana ApiKey (if not using a secret)
30+
apiKey: ""
2931
# -- Secret containing the Grafana API key
3032
apiKeySecret:
3133
# -- Name of the secret containing the API key
32-
name: "grafana-mcp-api-key"
34+
name: ""
3335
# -- Key within the secret that contains the API key
34-
key: "api-key"
36+
key: ""
3537

3638
# -- Enable debug mode
3739
debug: false

0 commit comments

Comments
 (0)