How to Configure OpenHands Kubernetes Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands kubernetes read only access by binding a restricted Kubernetes role to the agent identity. This role allows only read actions on specific cluster resources and blocks any write changes. Many teams start by giving AI agents broad cluster credentials to speed up testing. Broad permissions let an automated tool delete pods, change apps, or read secret keys by mistake. Scoping permissions down before the agent runs is the first step toward safe cluster checks. How openhands ku

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up openhands kubernetes read only access by binding a restricted Kubernetes role to the agent identity. This role allows only read actions on specific cluster resources and blocks any write changes. Many teams start by giving AI agents broad cluster credentials to speed up testing. Broad permissions let an automated tool delete pods, change apps, or read secret keys by mistake. Scoping permissions down before the agent runs is the first step toward safe cluster checks.

How openhands kubernetes read only access works in native RBAC

Kubernetes controls what an agent can do through Role-Based Access Control, or RBAC. In this system, a Role or a ClusterRole holds rules that define a set of permissions. These rules are additive, which means Kubernetes has no deny rules at all. You start with zero permissions and add each allowed read action one by one.

A standard Role sets permissions inside one single namespace. A ClusterRole is not tied to one namespace and covers cluster-wide objects like nodes. It can also cover namespaced objects across the whole cluster. To give the agent read rights, you list only read verbs in the role rules.

After you create the role, you attach it to the agent identity. A RoleBinding grants those permissions inside one specific namespace. A RoleBinding can point to a Role in that same namespace or to a global ClusterRole. If the agent must inspect every namespace, a ClusterRoleBinding grants that read scope across the entire cluster.

You also have to watch how RBAC handles subresources. Kubernetes names resources in RBAC just like they appear in the API URL. Some APIs have subresources, such as pod logs, written with a slash between the resource and subresource. If you want OpenHands to read pod logs for debugging, you must grant read rights to that subresource.

What native RBAC solves and what it leaves open

Native Kubernetes RBAC solves the basic problem of who can log in and which API endpoints they can call. When you bind a read role to OpenHands, the API server blocks direct requests to create or delete workloads. This stops the agent from tearing down deployments or changing cluster settings during a routine check.

Still, native RBAC only checks the resource type and the action verb when a request hits the API. It does not inspect the contents of the data returned to the agent in flight. If a read role includes secrets or config maps, the agent reads every key inside that namespace. Even pod logs often print user emails, phone numbers, card numbers, or national IDs in plain text.

Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Because RBAC is additive, teams often bundle broad read rules into one shared role for ease of use. Once the agent holds that credential, every command runs without a human check before execution. Native RBAC also requires you to distribute and rotate cluster credentials on the machine where the agent runs. If those credentials leak from the agent workspace, an attacker gains the exact same read view of your cluster.

Scoping subresources and sensitive objects

To tighten native RBAC, teams separate workload status checks from log and config reads. You can build a base role that only reads pod status, deployments, and events in one target namespace. You leave secret objects and exec subresources out of the role rules so the agent cannot run container commands.

When the agent needs to check logs across namespaces, a RoleBinding per namespace works better than one ClusterRoleBinding. This approach keeps the agent out of system namespaces and limits exposure to the apps under review. Still, native roles cannot rewrite sensitive strings inside log lines or require approval for one single read call.

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 Kubernetes RBAC block a single secret while allowing others in a namespace?

Kubernetes RBAC has no deny rules, because all permissions are purely additive. To allow only specific objects, you must list each allowed resource name instead of granting a blanket read rule.

Should I use a RoleBinding or a ClusterRoleBinding for an AI agent?

Use a RoleBinding whenever possible to keep the agent inside one specific namespace. A RoleBinding can still reference a shared ClusterRole while limiting the permissions to that single namespace.

How does OpenHands read pod logs without gaining shell access?

In Kubernetes RBAC, pod logs and pod exec are separate subresources written with a slash in the rule. Grant read permissions only on the log subresource and leave the exec subresource out of the role.

Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.

The query runs. The emails stay hidden.