Skip to content
LabLocal AI PlatformLocal AI Platform Labs · Part 9

Diagnosing Kubernetes Failures with MCP in Open WebUI: How Far Read-Only Access and a Local Model on an 8GB GPU Can Go

I connected a read-only Kubernetes MCP server to Open WebUI, had qwen3:8b diagnose five failure types and a healthy app, and measured what it got right and wrong.

Translated from the Korean original.

A local model on an 8GB GPU could find the root cause of Kubernetes failures through MCP, but simply connecting it was not enough. With the default Open WebUI setup, it did not produce a single accurate diagnosis in 18 attempts. After I turned off the built-in tools and made the system prompt persist, it got 12 right. The same model connected directly to the tools got 17 right, so tool count and context management mattered as much as model quality. Wrong answers still sound plausible, so this setup is safest as a lookup assistant that surfaces clues for a person to verify.

What we’re building

MCP (Model Context Protocol) is a standard way for models to call external tools. Here, Open WebUI acts as the MCP client and offers the tools of a Kubernetes query server to the model.

The model never touches the cluster directly. When it requests a tool call, Open WebUI calls the MCP server and passes the result back to the model.

Narrow the permissions first

This MCP server’s read_only setting keeps write tools from being registered, and its official docs say actual access control should be left to Kubernetes RBAC. So I restricted the configuration and the permissions separately.

config.toml
port = "8080"
stateless = true
read_only = true
toolsets = ["core"]
enabled_tools = ["pods_list_in_namespace", "pods_get", "pods_log", "events_list", "resources_get", "resources_list"]
list_output = "table"
[[denied_resources]]
group = ""
version = "v1"
kind = "Secret"

Permissions apply only to mcp-drill, the namespace used for diagnosis drills. Binding a ClusterRole with a RoleBinding makes it effective only inside that namespace.

RBAC
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: mcp-diagnose-read
rules:
- apiGroups: [""]
resources: [pods, pods/log, events, services, persistentvolumeclaims]
verbs: [get, list, watch]
- apiGroups: [apps]
resources: [deployments, replicasets, statefulsets, daemonsets]
verbs: [get, list, watch]
- apiGroups: [discovery.k8s.io]
resources: [endpointslices]
verbs: [get, list, watch]
- apiGroups: [events.k8s.io]
resources: [events]
verbs: [get, list, watch]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: k8s-mcp-read
namespace: mcp-drill
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: mcp-diagnose-read
subjects:
- kind: ServiceAccount
name: k8s-mcp
namespace: mcp

The MCP server’s own authentication is not enabled, so a NetworkPolicy allows connections only from the Open WebUI pod.

NetworkPolicy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: k8s-mcp-from-open-webui
namespace: mcp
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: k8s-mcp
policyTypes: [Ingress]
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: ai
podSelector:
matchLabels:
app.kubernetes.io/instance: open-webui
ports:
- port: 8080

I deployed it through Git by adding one more app to the Argo CD structure from the previous part of this series, then verified the boundaries with real calls.

Test Result
Read pods, logs, and events in mcp-drill Allowed
Read Secrets and ConfigMaps in mcp-drill Denied
Delete a pod, modify a Deployment, pods/exec Denied
List pods in the ai namespace Denied
Read a Secret through an MCP tool resource not allowed
Connect to MCP from a pod other than Open WebUI Blocked (timed out)
Regular user alice calls the diagnosis model Model not found
alice attaches the MCP tools to another model and calls it No tool calls

Which failures it had to diagnose

I created one healthy app and five kinds of failure in mcp-drill.

Scenario Injected problem What counts as an accurate answer
Image Nonexistent tag nginx:9.99-no-such-tag The image pull failure and the actual tag
Restart Missing required environment variable DATABASE_URL
Service Selector typo shopp The difference between the selector and the pod labels
Healthy None Says there is no problem
Memory Exceeds the 16Mi limit OOMKilled and the limit value
Readiness Nonexistent path /healthz The probe path and the 404

Automatic scoring sometimes accepted wrong answers or missed right ones, so I read the saved answers, corrected the criteria, and recounted everything as accurate, partial, or wrong.

Comparing models and prompts

First I compared models with the MCP tools connected directly, without Open WebUI. I ran the first four scenarios three times each, for 12 runs per condition.

Model Context Default prompt Procedure listing failure types
qwen3:8b 4096 6/12 12/12
qwen3:8b 8192 7/12 12/12
llama3.1:8b 4096 0/12 5/12
llama3.1:8b 8192 0/12 5/12

I excluded gemma3:4b because it does not support tools in Ollama. llama3.1:8b often said an existing pod did not exist or reported the cause of a different app.

The 12/12 was hard to believe, because the procedure prompt named the failure types being tested. When I added memory and Readiness failures that the prompt did not mention, the score fell to 2 out of 6, and the model sometimes misreported OOMKilled as an image error.

So instead of listing failure types, I rewrote it as a general procedure that says which fields to read. The prompt used in the test was in Korean:

1) pods_list_in_namespace로 질문한 앱의 파드를 찾습니다.
2) pods_get으로 containerStatuses(state, lastState.reason, exitCode, ready)와 resources, 프로브 설정을 읽습니다.
3) events_list에서 그 파드 이름의 이벤트만 봅니다.
4) 컨테이너가 시작된 적이 있으면 pods_log를 봅니다.
5) Service 문제면 Service의 spec.selector를 읽고 파드 labels와 비교합니다.
6) 확인한 필드 값을 그대로 인용하고, 확인하지 못한 것은 모른다고 답합니다. 다른 파드의 결과를 섞지 않습니다.

In English, for reference:

1) Use pods_list_in_namespace to find the pods of the app in question.
2) Use pods_get to read containerStatuses (state, lastState.reason, exitCode, ready), resources, and the probe settings.
3) In events_list, look only at events for that pod name.
4) If the container has ever started, check pods_log.
5) For a Service problem, read the Service's spec.selector and compare it with the pod labels.
6) Quote the field values you confirmed as they are, and say you don't know what you could not confirm. Do not mix in results from other pods.
qwen3:8b + general procedure Accurate Max input tokens
Context 4096 9/18 4,049
Context 8192 17/18 7,888

At 4096, the model often kept repeating queries until it hit the call limit. At 8192, the model still fit entirely on the GPU at 6.2GB. But I tuned this procedure against the same six scenarios, so 17/18 should not be read as an accuracy rate for failures it has never seen.

Why connecting Open WebUI dropped the score to zero

I registered the MCP server as Kubernetes 조회 (“Kubernetes lookup”) under Integrations > External Tool Servers in the admin settings. Screenshots are from the Korean Open WebUI; key text is translated in the captions.

Open WebUI admin settings, Integrations screen. The External Tool Servers section shows the Kubernetes lookup K8s connection
The External Tool Servers list, with the server registered as Kubernetes 조회 (Kubernetes lookup).

With the same setup connected to Open WebUI, none of the 18 runs produced an accurate answer. Most of the time the model called a tool once and then just summarized the pod list in English, even though the system prompt was in Korean. There were two causes.

First, Open WebUI sent the model 37 tools, including its built-in ones. That defeats the point of selecting only six MCP tools and fills the context quickly. Turning off the built-in tools in the model settings leaves just the six.

Second, the system prompt saved on the model was not included in the follow-up call after a tool ran. In the Open WebUI 0.13.4 code, follow-up calls skip applying the system prompt. So I attached a Filter, only to k8s-doctor, that inserts it directly into the messages of each incoming request.

k8s-doctor Filter
SYSTEM = "당신은 쿠버네티스 장애 진단 도우미입니다. ..."
class Filter:
def inlet(self, body: dict) -> dict:
messages = [m for m in body.get("messages", []) if m.get("role") != "system"]
body["messages"] = [{"role": "system", "content": SYSTEM}, *messages]
return body

The SYSTEM string begins “You are a Kubernetes failure diagnosis assistant.”

The context size had to be pinned as well. Open WebUI does not pass num_ctx over an OpenAI-compatible connection, so I created a dedicated model in LiteLLM.

LiteLLM values (excerpt)
- model_name: diagnose
litellm_params:
model: ollama_chat/qwen3:8b
api_base: http://ollama.ai.svc:11434
think: false
num_ctx: 8192
temperature: 0

Here are the results with the two causes measured separately.

Open WebUI configuration Accurate
Default (built-in tools on, model system prompt) 0/18
Built-in tools off only 0/18
Filter added only 3/18
Built-in tools off + Filter 12/18

What the final setup got right and wrong

Scenario Accurate What actually happened
Restart 3/3 Confirmed the missing DATABASE_URL from the logs
Healthy 3/3 Said there was no problem
Memory 3/3 Correct cause, but answered in English rather than Korean
Readiness 3/3 Correct cause, but answered in English rather than Korean
Image 0/3 Reported the pull failure but did not check the actual tag
Service 0/3 Ended with an empty answer after the tool calls

When I asked about the restart failure in the browser with the admin account, the model called the pod list, pod details, events, and log tools in order and answered that DATABASE_URL was missing.

k8s-doctor chat screen. Asked why the worker app restarts, the model calls k8s_pods_list_in_namespace, k8s_pods_get, k8s_events_list, and k8s_pods_log, then answers that a FATAL error occurred because the DATABASE_URL environment variable is not set
The prompt asks why the worker app in mcp-drill keeps restarting. After the four tool calls, the model answers that DATABASE_URL is unset, causing a FATAL error.

I could not fully explain why this scored lower than the 17/18 of the direct connection. In the requests I observed, a single pod YAML exceeded 10,000 characters and input reached 7,893 tokens, nearly touching the 8192 limit. When I reran the same Service question it answered correctly, so results can vary from run to run.

If you run this in production

  • Don’t treat the answer as a conclusion. Have a person check the tool calls and results shown with it.
  • Enforce permissions with RBAC and the network, not with prompts.
  • Enable only the tools you need. On local models, even tool descriptions consume context.
  • After changing a prompt, test again with failures the prompt doesn’t mention.
  • Query results include logs and configuration verbatim, so before widening access to sensitive namespaces, check what would be sent to the model.

What this lab did not verify

  • The scenarios are six that I built myself. I did not test overlapping failures or node and network failures.
  • I did not grant access to any real production namespace outside mcp-drill.
  • I did not test prompt injection through malicious instructions in logs or events.
  • I did not find the root cause of the empty Service answers in Open WebUI.
  • I did not restrict egress from the MCP server.

Summary

  • A read-only MCP setup needs read_only, RBAC, and NetworkPolicy together to have a clear boundary.
  • On an 8GB GPU, qwen3:8b with a context of 8192 worked best for tool calling, while llama3.1:8b and gemma3:4b were not a fit for this use.
  • A prompt that specifies which fields to read handled new failures better than one that lists failure types.
  • In Open WebUI, turning off the built-in tools and keeping the system prompt moved the result from 0/18 to 12/18.

How this post was made

The commands and numbers in this post are results I ran myself on a kind cluster on the same PC as the earlier parts of the series. The configuration follows the official kubernetes-mcp-server and Open WebUI docs and the installed Open WebUI 0.13.4 source. The 18-run evaluations used a script that sends the same chat requests as the browser, and I read the answers after automatic scoring to correct the verdicts. In a real browser, I checked one restart-failure diagnosis with the admin account and the connection screen. The users are fictional and secrets were kept only in Kubernetes Secrets. I used AI tools to help organize the run logs and write the post, and this English version was translated from the Korean original with an AI tool.

References