How to Configure Vercel AI SDK Kubernetes Prevent Delete
To set up a vercel ai sdk kubernetes prevent delete flow, limit role rules. You must leave out the delete verb when you bind the agent account. Engineering teams often connect language models to clusters to check pod status and logs. During early tests, developers sometimes attach broad admin roles to the agent identity. If a model misreads a prompt, a broad role lets it drop live workloads. How to set up vercel ai sdk kubernetes prevent delete rules The AI library uses tool definitions to tu
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.
To set up a vercel ai sdk kubernetes prevent delete flow, limit role rules. You must leave out the delete verb when you bind the agent account. Engineering teams often connect language models to clusters to check pod status and logs. During early tests, developers sometimes attach broad admin roles to the agent identity. If a model misreads a prompt, a broad role lets it drop live workloads.
How to set up vercel ai sdk kubernetes prevent delete rules
The AI library uses tool definitions to turn model text into cluster actions. When the model decides to act, the app sends a request to the API. The cluster checks the account token against its native role rules before running anything. In this system, permissions are purely additive, and there are no deny rules. To stop deletions, you never grant the delete verb in the first place.
You start by creating a dedicated service account for your AI app. Next, you define a Role to set permissions within a single namespace. If the agent needs to check nodes across all namespaces, you use a ClusterRole. Inside that role, you list only safe read verbs like get and list. You then link the account to the role with a RoleBinding or ClusterRoleBinding.
Many teams also want their AI agents to read pod output for debugging. The API treats pod logs as a subresource written with a slash. You can grant read rules to the pod log subresource without allowing pod removal. This keeps the agent helpful while blocking direct removal calls at the API level.
What native roles solve and what they leave open
Native roles are great at deciding which account can call specific API endpoints. If the model tries to remove a deployment, the API blocks the call right away. This works well for simple bots that only read status fields and events.
The gap appears when an agent needs to run fixes or restart stuck apps. To run commands inside a container, the role must allow the pod exec subresource. Once you grant exec access, the API cannot see what happens inside the shell. A model could still run a shell command that wipes files or drops tables.
AI Data Exfiltration Prevention + Kubernetes RBAC: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static roles also apply the same rules to every single tool call all day. If an agent needs temporary delete rights to clear a bad pod, roles keeps the session active. You cannot ask a human to approve one single delete call through native roles. The cluster also stores raw secrets that an over-privileged role might read by mistake. When sensitive data like emails or card numbers enters logs, raw text returns to the model. Masking rewrites matched fields in results so raw emails or phone numbers do not leak.
Separating read tools from write tools in your app
Good design starts inside the code where you define the model tools. Do not build one giant tool that takes any raw resource and action verb. Instead, build small tools that only perform one narrow task at a time. Make one tool that fetches pod status and another that reads recent log lines.
Keep destructive actions out of the tool list you send to the model. If the model does not have a delete tool, it is less likely to try. Pair this app design with strict cluster roles so both layers block bad calls. Always test your agent in a staging namespace before giving it production credentials. Check your cluster logs often to see which endpoints the agent calls most.
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 write a deny rule in Kubernetes RBAC to block deletes?
No, Kubernetes role permissions are purely additive and do not support deny rules. To block deletes, you must create a role that leaves out the delete verb. Make sure the agent account is not bound to any other broad roles.
How do I let the Vercel AI SDK read logs without deleting pods?
Create a Role that lists only the pods and pods log subresource targets. Grant only read verbs like get and list on those two specific items. Bind this role to the service account your AI app uses to log in.
Why is the pod exec subresource risky for AI agents?
Granting access to the pod exec subresource lets the agent open a container shell. RBAC only checks if the account can start the session, not the shell commands. An agent could delete files inside the container even without cluster delete permissions.
Related guides
In this post