How to Configure Mastra Kubernetes Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up mastra kubernetes approval by pausing agent tools until a human reviews them. You also pair those agent steps with strict cluster role rules. Many teams start by giving their AI agents broad cluster credentials for fast testing. When an agent holds wide permissions, one bad prompt can delete active workloads. How mastra kubernetes approval works with cluster roles A safe setup starts inside the cluster API server with role-based access control. In Kubernetes, a Role sets permission

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 mastra kubernetes approval by pausing agent tools until a human reviews them. You also pair those agent steps with strict cluster role rules. Many teams start by giving their AI agents broad cluster credentials for fast testing. When an agent holds wide permissions, one bad prompt can delete active workloads.

How mastra kubernetes approval works with cluster roles

A safe setup starts inside the cluster API server with role-based access control. In Kubernetes, a Role sets permissions inside one single namespace. A ClusterRole sets rules across the whole cluster and covers cluster-scoped resources like nodes. Permissions in Kubernetes are only additive, and there are no deny rules at all. You bind these rules to an agent identity using a RoleBinding or ClusterRoleBinding.

Agents often need to read pod logs or run commands inside a container. Kubernetes treats those actions as subresources on the pod API path. You must grant specific rules for the log subresource or the exec subresource. On the agent side, Mastra lets builders mark sensitive tool calls for human review. When the agent picks a cluster tool, the workflow pauses and waits for approval. A human reviewer checks the pending action and approves or rejects the run. Only after that sign-off does the agent send the request to the cluster API.

Why native roles and workflow pauses fall short

Native roles and agent pauses solve the first layer of cluster safety. Role bindings decide which service account can talk to the cluster API server. Workflow pauses make sure a person checks the tool inputs inside the Mastra app. Together, they stop unapproved agents from hitting the cluster on their own.

Still, a large gap remains once the request leaves the agent framework. Kubernetes role rules check who logs in and which API resource they hit. Once a role grants pod exec access, the API server does not inspect shell commands. A service account with exec rights in a namespace can run any command inside those pods. If an agent holds static cluster keys, it can also bypass app-level pauses during a bug. Also, pod logs or database outputs inside the cluster often hold raw user data. Native cluster roles cannot rewrite emails, phone numbers, card numbers, or national IDs in results.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What to review before approving agent cluster actions

Teams should set clear rules for reviewers who check pending agent actions. First, check the exact namespace and resource name in the agent tool request. Prefer namespace RoleBindings over ClusterRoleBindings so a mistake stays in one area. Keep read tools like pod logs separate from write tools like pod exec. That way, an agent can read status data while write actions pause for a human.

Second, check what data the command will return to the agent model. Shell commands and log reads can pull secrets or personal data into the prompt context. Reviewers need to know which container the agent will touch and why. Still, human reviewers can miss small flags in a long command string. Teams need runtime controls that inspect every single command and mask sensitive output fields.

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 specific shell commands inside a pod exec session?

No, Kubernetes RBAC only checks if the user or agent can use the pod exec subresource. Once the API server allows the session, RBAC cannot filter individual shell commands.

Should an AI agent use a RoleBinding or a ClusterRoleBinding?

Use a RoleBinding whenever the agent only works in one specific namespace. A ClusterRoleBinding grants access across all namespaces, which raises the risk of a wide mistake.

How do you stop agents from reading sensitive data in pod logs?

Native pod log permissions give full read access to the entire log stream. To hide emails, phone numbers, or card numbers, you must rewrite matched fields in results.

The query runs. The emails stay hidden.