How to Configure OpenHands Kubernetes Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands kubernetes permissions by binding a native Role to an agent account. You must scope those rules to a single namespace so the agent stays safe. Many teams start by giving their coding agent broad cluster admin rights for speed. That fast setup creates big risks when an autonomous agent runs the wrong command. A broad role lets the agent change workloads, read secrets, or delete active pods. How openhands kubernetes permissions work in native RBAC Kubernetes uses Role-Based

Kubernetes RBAC + AI Agent Permissions: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up openhands kubernetes permissions by binding a native Role to an agent account. You must scope those rules to a single namespace so the agent stays safe. Many teams start by giving their coding agent broad cluster admin rights for speed. That fast setup creates big risks when an autonomous agent runs the wrong command. A broad role lets the agent change workloads, read secrets, or delete active pods.

How openhands kubernetes permissions work in native RBAC

Kubernetes uses Role-Based Access Control to manage what users and bots can do. Every rule in this system is additive, which means there are no deny rules. You start with zero rights and add explicit verbs like read, list, or watch. A standard Role always sets rules inside one specific namespace for your agent.

If your agent needs to see nodes or resources across all namespaces, you use a ClusterRole. A RoleBinding connects your agent identity to a Role inside one target namespace. You can also link a RoleBinding to a shared ClusterRole to limit it to one namespace. A ClusterRoleBinding gives the agent rights across the whole cluster at once.

For coding agents like OpenHands, you should stick to a single namespace RoleBinding. You also need to watch out for API subresources like pod logs and pod exec. In native RBAC, you write these subresources with a slash between the resource and action. Giving an agent pod log rights lets it read output to debug broken apps. Giving it pod exec rights lets the agent run shell commands inside running containers.

Why you should separate read roles from write roles

Autonomous agents work in loops where they read state, plan a fix, and run changes. If you put read and write verbs in the same role, the agent always has write power. A better pattern splits your setup into two distinct roles for different tasks. The first role only grants read verbs on pods, deployments, and pod logs.

With this read role, OpenHands can check why a pod crashed without changing the cluster. It can inspect container status and read log subresources to find the root bug. When the agent needs to test a fix, it should use a separate sandbox namespace. In that sandbox namespace, a RoleBinding can grant create and update verbs on deployments.

Kubernetes RBAC + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You should avoid granting secret read rights or pod exec rights in shared namespaces. If an agent can exec into a pod, it can use that pod's own identity. It can also read local files or environment variables inside that running container.

What native RBAC solves and what it leaves open

Native roles and bindings do a great job of limiting which API paths an agent can call. They stop an agent in a test namespace from deleting apps in your main namespace. They also let you block access to sensitive subresources when the agent only needs status checks.

Still, native RBAC only checks who logs in and which API resource they hit. Once you grant pod exec or pod log rights, RBAC does not inspect the data inside. If pod logs contain customer emails, phone numbers, or card numbers, the agent gets them raw. If you grant exec rights, RBAC cannot pause a dangerous shell command inside the container. Native rules decide if the door opens, not what individual commands or outputs do in flight.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source HTTP proxy, a sidecar for your Kubernetes API. The kubectl client changes only the server address it talks to while RBAC stays in place.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs. Every request and verdict is logged without storing bearer tokens. View the project on GitHub.

Frequently asked questions

Should I give OpenHands a ClusterRoleBinding for debugging?

No, a ClusterRoleBinding gives the agent access across every namespace in your cluster. If you want to reuse a ClusterRole, bind it with a namespace RoleBinding instead. That keeps the agent restricted to one safe namespace during its task.

How do I let OpenHands read pod logs without giving it shell access?

In your Role rules, grant read access to the pod log subresource only. Do not include the pod exec subresource in that same Role definition. Since RBAC rules are additive, leaving out exec blocks shell access inside containers.

Can native Kubernetes RBAC block a single dangerous command inside a pod exec session?

No, native RBAC only authorizes the initial request to open the exec subresource. Once the exec stream starts, RBAC does not inspect or filter the shell commands run inside.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.