How to Configure OpenAI Agents SDK Kubernetes Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an openai agents sdk kubernetes approval workflow by linking agent tools to cluster roles and human checks. The agent prepares a cluster action, waits for a reviewer to approve it, and then runs the request. Teams often start by giving an agent a single cluster credential so it can check pods and fix issues fast. When that role is too broad, a bad prompt or model error can delete workloads across namespaces. How an openai agents sdk kubernetes approval workflow operates In the Open

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 an openai agents sdk kubernetes approval workflow by linking agent tools to cluster roles and human checks. The agent prepares a cluster action, waits for a reviewer to approve it, and then runs the request. Teams often start by giving an agent a single cluster credential so it can check pods and fix issues fast. When that role is too broad, a bad prompt or model error can delete workloads across namespaces.

How an openai agents sdk kubernetes approval workflow operates

In the OpenAI Agents SDK, you define tools as Python functions that the model can call during a run. Each tool takes structured inputs from the model and sends requests to the Kubernetes API server. Before the tool sends a write request, your code pauses the run and sends the details to a human reviewer. The reviewer checks the target namespace, resource kind, and action before clicking approve or reject.

On the cluster side, Kubernetes Role-Based Access Control sets what the agent service account can do. A Role or ClusterRole holds rules that represent a set of permissions. In Kubernetes, these permissions are purely additive, and there are no deny rules. A Role sets permissions inside one namespace, while a ClusterRole covers cluster-wide resources or all namespaces.

You attach those rules to the agent identity with a RoleBinding or a ClusterRoleBinding. A RoleBinding grants permissions inside one namespace and can point to a Role or a ClusterRole. A ClusterRoleBinding grants access across the whole cluster. When you scope the agent to a single namespace with a RoleBinding, you limit the blast radius of any approved tool call.

Why native cluster roles and code checks fall short

Splitting read tools from write tools in your agent code is a good first step. You can let the agent read pod status on its own and pause for approval before changing a deployment. Kubernetes also handles subresources like pod logs or pod exec paths as distinct entries in the API URL. You can grant log reading without granting pod creation or deletion.

Still, native roles only check who logs in and which API resource they touch. Once the agent holds an active credential, the cluster cannot tell if a human approved that specific call in your app. If a developer adds a new tool function and forgets the approval check, the cluster runs the request right away. Also, if the agent has permission to run commands inside a pod, Kubernetes does not inspect the shell commands inside that stream.

Approval Chains & Escalation + Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Scoping agent permissions and review steps in production

To keep cluster tasks safe, teams break agent capabilities into small, narrow functions. Instead of one general tool that takes raw API paths, build separate functions for scaling, restarting, or reading logs. Give the agent service account a Role that only allows the exact verbs those functions need. Avoid ClusterRoleBindings unless the agent must check nodes or other cluster-scoped objects.

You also need a clear audit trail that links the model prompt, the human reviewer, and the cluster change. Native Kubernetes logs only show the service account name that made the API call. They do not record which user clicked approve in chat or why the agent proposed the change. Keeping the credential on the agent host also means any bug in the app code can use that key without waiting for review.

Govern kubectl and API calls in flight

Identity providers and Kubernetes RBAC decide who logs into a cluster. They cannot redact keys inside returned JSON objects or hold a risky delete call for review. By design, hoop.dev runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. Next, hoop.dev data masking rewrites sensitive keys in returned Secret, ConfigMap, and log responses in memory, and writes each decision to the audit trail. Explore the repo on GitHub.

Frequently asked questions

Can Kubernetes RBAC block specific commands inside an agent exec call?

No, Kubernetes RBAC only checks if the role can call the exec subresource on a pod. It does not read or filter the shell commands that run after the stream opens.

Should an OpenAI agent use a RoleBinding or a ClusterRoleBinding?

Use a RoleBinding whenever possible to keep the agent inside a single namespace. A ClusterRoleBinding grants permissions across the entire cluster, which raises the risk if an agent tool makes a mistake.

Why is code-level approval in the agent app not enough on its own?

When the agent app holds the cluster key, a code bug or skipped check lets the model call the API directly. Enforcing approval outside the agent code ensures no write call reaches the cluster without sign-off.

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.