fix: set --allowed-hosts for bundled grafana-mcp deployment#2260
fix: set --allowed-hosts for bundled grafana-mcp deployment#2260muskiteer wants to merge 5 commits into
Conversation
Fixes kagent-dev#2166 Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the bundled grafana-mcp Helm deployment so it can be initialized successfully as a RemoteMCPServer when using streamable-http, by automatically adding an --allowed-hosts value that matches the chart-generated Kubernetes Service DNS name.
Changes:
- Add
--allowed-hosts=<fullname>.<namespace>:<service.port>to thegrafana-mcpcontainer args in the Helm Deployment template. - Add a Helm unit test assertion verifying the rendered Deployment includes the expected
--allowed-hostsargument.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| helm/tools/grafana-mcp/templates/deployment.yaml | Automatically injects --allowed-hosts based on the chart’s generated Service hostname and port. |
| helm/tools/grafana-mcp/tests/deployment_test.yaml | Adds coverage to ensure --allowed-hosts is present in the rendered container args. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
|
I've made allowedHosts configurable and added sensible defaults for the Kubernetes Service DNS variants while still allowing users to override them (including Happy to receive any further feedback @mesutoezdil @onematchfox |
|
and branch is out-of-date |
Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
Description
What does this PR do?
This PR fixes an out-of-the-box initialization failure for the bundled
grafana-mcpdeployment.Why is it needed?
Currently, when
kagent-grafana-mcpis enabled in the default Helm chart, it fails to initialize as aRemoteMCPServerbecause of aForbiddenerror. This happens because recent versions ofmcp-grafanavalidate the HTTP Host header forstreamable-httptransports as DNS rebinding protection (introduced ingrafana/mcp-grafana#957). Without passing--allowed-hostsmatching the internal Kubernetes service DNS name, requests from the Kagent controller are rejected.How does this fix it?
This automatically resolves the Kubernetes Service DNS name natively generated by the chart (
<fullname>.<namespace>:<port>) and appends it to the container's--allowed-hostsarguments in the deployment spec. This ensures the bundled integration works immediately without manual configuration.Testing
How was this tested?
make create-kind-cluster).make helm-install), which enabledgrafana-mcp.kagent-grafana-mcpRemoteMCPServer successfully transitions toAccepted: Trueinstead ofReconcileFailed: Forbidden.Fixes #2166