feat(kiali): add meshCluster parameter for multi-cluster support#1224
feat(kiali): add meshCluster parameter for multi-cluster support#1224hhovsepy wants to merge 6 commits into
Conversation
| - **`clusterName`** (Istio mesh level): Most Kiali tools accept an optional `clusterName` parameter that tells Kiali which mesh cluster to query. This is passed in the request body to Kiali's API. When omitted, Kiali defaults to its home cluster. Use `kiali_list_clusters` to discover the available mesh cluster names. | ||
|
|
||
| In a multi-cluster Istio mesh, both parameters may be needed: `context` to authenticate with the correct credentials, and `clusterName` to target a specific mesh cluster within Kiali's view. |
There was a problem hiding this comment.
This seems very complex for models to figure out.
Is there a reason for this to be going through a secondary multi cluster level rather than implementing a cluster provider interface (like the one kcp did, or what is in pkg/kubernetes) ?
There was a problem hiding this comment.
The reason is that Kiali mesh clusters don't map to the Provider interface's model:
GetDerivedKubernetes(ctx, target)assumes each target is a distinct
Kubernetes API server with its own credentials. Kiali mesh clusters
are not — a single Kiali instance (one URL, one bearer token) already
sees all mesh clusters.GetDerivedKubernetes("east")and
GetDerivedKubernetes("west")would return the same client.- Only one provider can be active. A Kiali provider would replace the
kubeconfig provider, losing multi-context support. - Kiali handles multi-cluster routing internally via Istio's remote
secrets. The MCP server just passesclusterNamein the POST body
as a query-scope parameter — same pattern asnamespaceon other tools.
I've simplified the docs to remove the dual-parameter explanation —
models only need to know about clusterName and kiali_list_clusters.
The context injection is already handled by the provider layer
transparently.
There was a problem hiding this comment.
well the provider layer (while handling this transparently for toolsets) would expose this parameter to the models. My main concern is models getting confused over needing to set both a context and a clusterName for tool calls.
Maybe we can change the param to be a mesh cluster name or similar (just to clarify that this is for a mesh cluster, and not to select the actual target cluster).
E.g. if this is used with the ACM provider, this would lead to a model having both cluster and clusterName set as tool params, which would obviously be confusing
There was a problem hiding this comment.
Thank you for the clarification, I have renamed the clusterName param to 'meshCluster', will it be non confusing now?
There was a problem hiding this comment.
I think the proposal of @Cali0707 makes sense, using a meshCluster parameter.
I understand the first proposal of creating a provider, so instead of clusterName being visible in the schema, the MCP would intercept the context parameter and translate it transparently to clusterName inside the Kiali handler before forwarding to Kiali.
The main issue is that the context name is not the Kiali cluster name, and it is not really a context change but a filter for Kiali, so probably it would need something extra in the configuration, like a cluster mapping.
For that reason, I think a meshCluster parameter would be more appropriate. Unlike context, which is a Kubernetes connection concept tied to kubeconfig (What Kiali should I use), meshCluster is explicitly scoped to the service mesh topology as Kiali understands it (What clusters from the mesh I want to check?), making the semantic boundary clear to both the model and the operator.
I will test this with Claude and see if there is any issue on the approach.
33c627e to
882ea63
Compare
|
I discussed this internally with @josunect Ideally, in order to keep things easy for models, it might be better we have a uniform way to access multi-cluster (this is what we have built in with the tool mutator) I think the active thread with Calum is also about this. I'm not sure if Josune did some research and findings. |
|
@manusa I was doing some tests, when I ask from a specific cluster, Kiali returns the right data (using the MeshCluster arg). When asking for an specific context, it did a wrong call (With no previous knowledge), but next it made the right call. When asking for an specific context, it choose to use the kubernetes tool (When available). Maybe we could use a new toolset config to be able to do a cluster mapping from context to cluster name and avoid this kind of issue. |
|
Another issue found, is that the MCP can pass the context to kiali, but, it is ignored, and Kiali returns the results from the home cluster (What happens in multi cluster when no cluster is passed). So, it can provide wrong results. Maybe, if list clusters return the cluster name and the context, it could help. |
aljesusg
left a comment
There was a problem hiding this comment.
Sorry, I was away last week; I agree with the proposed solution.
|
👋 Heads up — this pull request changes files owned by @aljesusg @josunect. You are listed as an owner of one or more of the changed areas in |
efd84bb to
6e0880f
Compare
Expose an optional meshCluster parameter on eight Kiali tools to target a specific Istio mesh cluster. The value is remapped to clusterName when calling the Kiali API. Add kiali_list_mesh_clusters so models can discover mesh cluster names before calling other tools. Mark all Kiali tools as not cluster-aware so the MCP server does not inject context on them; mesh scope is selected only via meshCluster. Related: kiali/kiali#9927, kiali/kiali#9981 Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Hayk Hovsepyan <hhovsepy@redhat.com>
@josunect I don't think this would work directly, this would be where you need a provider 🫠 The issue is that the provider is called to select a kube client before the toolset's tool is invoked, so we can't easily have the toolset change which cluster it is targetting... A couple ideas that may work:
IMO option 3 seems like the easiest approach here. If that doesn't work as well as we like, my vote would be to try for option 1. I'd be happy to help with some of the work there, as I built out the providers originally |
@Cali0707 we were testing this approach (3) in the Kiali mcp itself, and worked fine. I think the risk here is that the mcp doesn't provide the cluster parameter to Kiali, in that case, Kiali will return the data from the home cluster. Maybe writing a provider for Kiali multi cluster that includes the cluster name from the kube config as the mesh cluster parameter? |
|
@josunect maybe we can create some eval scenarios to capture this problem and see how prevalent it is? |
Yes, we can create some evals for this. I guess we can create 2 jobs for the same workflow? And a new make target to setup a multi cluster environment. |
Signed-off-by: Hayk Hovsepyan <hhovsepy@redhat.com>
Gateway API CRDs are not required by Kiali evals or Bookinfo setup. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Hayk Hovsepyan <hhovsepy@redhat.com>
Make invokes /bin/sh by default; dash does not support pipefail used by setup-kiali-multicluster and related targets. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Hayk Hovsepyan <hhovsepy@redhat.com>
-kv dev pushes a local image but Kiali only builds it when KIALI_BUILD_DEV_IMAGE=true. Export that for dev setups and add Node 24 + corepack to the multicluster workflow job. Also fix check-trigger suite output wiring so the multicluster job runs when suite is kiali. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Hayk Hovsepyan <hhovsepy@redhat.com>
Signed-off-by: Hayk Hovsepyan <hhovsepy@redhat.com>
|
@Cali0707 we have added some multi cluster evals. It looks like it is working as expected. |
|
Thanks @josunect - one question (sorry for not thinking of this earlier): can you pull the multi cluster eval CI changes into a separate PR? We've had lots of issues iteration there recently and I want to make sure we get this piece right, without blocking the rest of this PR |
Summary
Adds multi-cluster support to the Kiali toolset for kiali/kiali#9895.
meshClusteron eight Kiali tools — optional Istio mesh cluster name (e.g.west). Remapped internally to Kiali'sclusterNameAPI parameter viaremapMeshCluster().kiali_list_mesh_clusters— discovery tool returning mesh clusternameandisHome.ClusterAware: falseon all Kiali tools — the MCP server does not injectcontexton Kiali tools; mesh scope is selected only viameshCluster. Core Kubernetes tools still usecontextwhen multi-cluster is enabled.evals/tasks/kiali/multicluster/(mesh status, list clusters, remote metrics/workloads/topology/traces), plussetup-kiali-multicluster/run-evals-multiclusterMakefile targets and CI job whensuite=kiali.Tools with
meshCluster:get_mesh_traffic_graph,get_metrics,get_logs,get_pod_performance,list_or_get_resources,list_traces,manage_istio_config,manage_istio_config_read.Why
Kiali exposes mesh cluster names (
east,west, …), not kubeconfig context names. Auto-mapping MCPcontext→ mesh cluster would fail silently in production and conflate two different concepts:contextmeshClusterModels should call
kiali_list_mesh_clusterswhen the target cluster is unknown, then pass thenamevalue asmeshCluster. Prompt guidance for the Kiali chatbot lives upstream in kiali/kiali#9981.Test plan
go test ./pkg/mcp/...(includeslist_mesh_clustersintegration test andTestKialiToolsNotClusterAware)run-evaluation-multiclusterforsuite=kialieast/west)meshCluster=westkiali_list_mesh_clustersfirstRelated