How to Configure OpenHands Kubernetes Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an openhands kubernetes audit log by turning on API server audit policies. Next, you bind a scoped role to the agent service account. Engineering teams often connect autonomous coding agents to clusters using wide admin roles. This quick path lets the agent deploy apps and check pod logs right away. Still, wide roles let an autonomous agent change cluster state or read sensitive secrets. When an agent runs a bad command, teams need clear logs to see what happened. How the openhands

Audit Log Integrity + Kubernetes Audit Logs: 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 an openhands kubernetes audit log by turning on API server audit policies. Next, you bind a scoped role to the agent service account. Engineering teams often connect autonomous coding agents to clusters using wide admin roles. This quick path lets the agent deploy apps and check pod logs right away. Still, wide roles let an autonomous agent change cluster state or read sensitive secrets. When an agent runs a bad command, teams need clear logs to see what happened.

How the openhands kubernetes audit log and RBAC work

Kubernetes controls agent actions through role-based access control on the API server. In this system, a Role or ClusterRole holds rules that represent a set of permissions. These permissions are purely additive, which means there are no deny rules at all. A standard Role always sets permissions within one single namespace. A ClusterRole is not namespaced and can cover cluster-wide resources like nodes. It can also cover namespaced resources across all namespaces in your cluster.

To grant these rules to OpenHands, you create a RoleBinding or a ClusterRoleBinding. A RoleBinding grants permissions inside one namespace and can reference a Role or a ClusterRole. A ClusterRoleBinding grants access across the entire cluster. When OpenHands runs, it sends requests to the API server using its assigned identity. The API server checks the bound role and records the request in the audit log.

Kubernetes RBAC refers to resources by the same name that appears in the API URL. Some APIs use a subresource, such as a pod log or an exec call. In RBAC rules, you write the subresource with a slash between the resource and subresource. If OpenHands needs to read pod logs or run commands, you must grant those subresources. Each call to a subresource creates an entry in the cluster audit log.

What native roles and audit logs leave open

Native roles and audit logs solve the first layer of cluster security. They verify which service account sent an API call and record the API event. This helps platform teams see when an agent creates a pod or reads a log. It also stops the agent from touching namespaces outside its RoleBinding.

Audit Log Integrity + Kubernetes Audit Logs: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, native setup only checks who logs in and which API endpoint they hit. Once the API server allows a pod exec subresource call, the agent opens a shell. Native RBAC does not inspect the shell commands that run inside that open stream. Native audit logs record that the exec call started, not the inner shell output. If a pod log holds emails, phone numbers, card numbers, or national IDs, raw data flows back. Native tools do not rewrite matched fields in results before the agent reads them. They also cannot pause a single risky shell command for human approval in flight.

Scoping agent permissions before turning on logging

Start by removing any cluster-wide bindings from the OpenHands identity. Create a dedicated namespace for the agent and its target workloads. Build a namespace Role that grants only the specific verbs and resources the agent needs. Separate read rules for pod logs from write rules that start pod exec sessions. Bind this Role to the agent identity with a RoleBinding in that single namespace. Finally, review your API server audit output to confirm that every agent request appears clearly.

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

Can I add a deny rule to block OpenHands from one secret?

No, Kubernetes RBAC permissions are purely additive and have no deny rules. You must list only the exact resources the agent is allowed to read.

How do I let OpenHands read pod logs without full pod edit rights?

You grant read permissions on the specific pod log subresource inside your Role. In RBAC rules, subresources are written with a slash after the main resource name.

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

Use a RoleBinding so the agent only gets permissions inside one specific namespace. A ClusterRoleBinding grants access across the whole cluster, which is too broad for agents.

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.