Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions helm/tools/grafana-mcp/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,19 @@ Join registry/repository for grafana-mcp image, skipping empty segments, then ap
{{- $img := .Values.image -}}
{{- $parts := compact (list $img.registry $img.repository) -}}
{{- printf "%s:%s" (join "/" $parts) $img.tag -}}
{{- end -}}

{{- define "grafana-mcp.allowedHosts" -}}
{{- if .Values.allowedHosts -}}
{{- join "," .Values.allowedHosts -}}
{{- else -}}
{{- $fullname := include "grafana-mcp.fullname" . -}}
{{- $ns := .Release.Namespace -}}
{{- $port := .Values.service.port | int -}}
{{- join "," (list (printf "%s:%d" $fullname $port)
(printf "%s.%s:%d" $fullname $ns $port)
(printf "%s.%s.svc:%d" $fullname $ns $port)
(printf "%s.%s.svc.cluster.local:%d" $fullname $ns $port)
(printf "localhost:%d" $port)) -}}
{{- end -}}
{{- end -}}
1 change: 1 addition & 0 deletions helm/tools/grafana-mcp/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spec:
args:
- --transport
- streamable-http
- --allowed-hosts={{ include "grafana-mcp.allowedHosts" . }}
{{- with .Values.args }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down
30 changes: 29 additions & 1 deletion helm/tools/grafana-mcp/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,32 @@ tests:
value: grafana:latest
- notMatchRegex:
path: spec.template.spec.containers[0].image
pattern: "^/" # no leading slash
pattern: "^/" # no leading slash

- it: should configure allowed-hosts with default DNS variants
template: deployment.yaml
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --allowed-hosts=RELEASE-NAME-grafana-mcp:8000,RELEASE-NAME-grafana-mcp.NAMESPACE:8000,RELEASE-NAME-grafana-mcp.NAMESPACE.svc:8000,RELEASE-NAME-grafana-mcp.NAMESPACE.svc.cluster.local:8000,localhost:8000

- it: should use custom allowedHosts when configured
template: deployment.yaml
set:
allowedHosts:
- "custom-host:8000"
- "*.kagent:8000"
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --allowed-hosts=custom-host:8000,*.kagent:8000

- it: should allow wildcard allowedHosts
template: deployment.yaml
set:
allowedHosts:
- "*"
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --allowed-hosts=*
7 changes: 7 additions & 0 deletions helm/tools/grafana-mcp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ resources:
cpu: 500m
memory: 512Mi

# allowedHosts configures the --allowed-hosts argument for mcp-grafana's Host header
# validation (required for streamable-http transport). When empty, defaults to the
# standard Kubernetes Service DNS variants (<name>.<namespace>, <name>.<namespace>.svc,
# <name>.<namespace>.svc.cluster.local, localhost). Override with a list of hosts or
# set to ["*"] to allow all hosts.
allowedHosts: []

# Additional Arguments for the mcp server
args: []

Expand Down