How to Configure OpenHands Kubernetes MCP Server
You set up an openhands kubernetes mcp server by linking an agent to cluster roles. You give the server a config file and bind it to strict Kubernetes RBAC rules. Many teams start by giving the agent broad cluster rights to speed up testing. When roles are too wide, the agent can delete pods or read private keys across namespaces. A safe setup scopes the agent to one namespace and limits what it can run. How the openhands kubernetes mcp server architecture works OpenHands runs as an autonomou
Kubernetes API Server Access + End-to-End Encryption: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up an openhands kubernetes mcp server by linking an agent to cluster roles. You give the server a config file and bind it to strict Kubernetes RBAC rules. Many teams start by giving the agent broad cluster rights to speed up testing. When roles are too wide, the agent can delete pods or read private keys across namespaces. A safe setup scopes the agent to one namespace and limits what it can run.
How the openhands kubernetes mcp server architecture works
OpenHands runs as an autonomous coding agent that uses tools to fix bugs and ship code. The Model Context Protocol server translates agent requests into standard Kubernetes API calls. When the agent needs to check a pod, it sends a request to the server. The server then talks to the Kubernetes API server using a local account or token.
Kubernetes checks every call through Role-Based Access Control on the API server. In Kubernetes RBAC, rules are purely additive, which means there are no deny rules. You start with zero rights and add only the exact actions the agent needs. A Role sets permissions inside a single namespace for local tasks. A ClusterRole sets permissions across the whole cluster and covers cluster-scoped items like nodes.
To grant these rights to the server, you create a binding in the cluster. A RoleBinding grants permissions inside one namespace and can point to a Role or ClusterRole. A ClusterRoleBinding grants access across the entire cluster at once. For an AI agent, a namespace RoleBinding keeps the blast radius small and safe.
Scoping pod logs and subresources in Kubernetes RBAC
Agents often need to read pod logs or run commands inside a running container. Kubernetes RBAC refers to resources by the exact name that appears in the API URL. Some API calls use a subresource, such as a pod log or an exec stream. In RBAC rules, you write the subresource with a slash, like pods and log.
If you only grant rights to pods, the agent still cannot read the logs. You must add a rule for the log subresource so the server can fetch output. The same rule applies when the agent runs a shell command through the exec subresource. Granting exec rights lets the agent run arbitrary commands inside the container process. Teams should leave out exec rights unless the agent must debug live processes directly.
Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native RBAC solves and what it leaves open
Native Kubernetes RBAC controls which API endpoints the server can call during a task. It stops an agent in one namespace from changing workloads in another namespace. It also blocks the server from reading cluster secrets if you leave secrets out of the Role. This setup decides who can log in and which resource types they can touch.
Still, native RBAC does not inspect what happens inside an allowed request in flight. Once a Role allows the exec subresource, Kubernetes does not check the shell commands sent. Once a Role allows pod logs, Kubernetes does not rewrite sensitive data in those logs. Pod logs often hold user emails, phone numbers, card numbers, or national IDs from app errors. If an agent can update a deployment, RBAC cannot pause a bad image change for human review. Teams still need a way to check individual commands and mask sensitive fields in results.
Add request guardrails and response masking beside Kubernetes
Cluster roles and service accounts govern who reaches the Kubernetes API. Still, a broad role or agent can delete workloads or print sensitive values from ConfigMaps and logs. In practice, hoop.dev runs beside the API server as a sidecar for your Kubernetes API and checks every request and response alongside RBAC.
With hoop.dev Kubernetes controls, guardrails can allow listing Secret names while refusing reads of Secret data before execution. Data masking redacts matched keys in returned JSON responses and log streams in memory. Furthermore, hoop.dev holds SOC 2 Type II and is MIT licensed on GitHub.
Frequently asked questions
Can I block specific actions with a deny rule in Kubernetes RBAC?
No, Kubernetes RBAC rules are purely additive and do not support deny rules. You must start with an empty Role and add only the verbs and resources needed.
Why should I use a RoleBinding instead of a ClusterRoleBinding for OpenHands?
A RoleBinding limits the agent to one specific namespace inside your cluster. A ClusterRoleBinding gives the agent permissions across all namespaces and cluster-wide nodes at once.
How do I let the server read pod logs without allowing container shell commands?
Grant read rights to the pod log subresource in your Role rule. Leave the pod exec subresource out of the Role so the agent cannot run commands.
Related guides
In this post