How to Configure CrewAI Kubernetes Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up crewai kubernetes read only access by binding a restricted role to the agent identity. This native setup limits the agent so it can only read cluster state and logs. Teams often start by handing an agent a broad admin file during early tests. That shortcut lets an autonomous task delete pods or read secret keys across every namespace. Scoping the role before the agent runs stops accidental changes to your live cluster. How crewai kubernetes read only access works in native RBAC Kub

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 crewai kubernetes read only access by binding a restricted role to the agent identity. This native setup limits the agent so it can only read cluster state and logs. Teams often start by handing an agent a broad admin file during early tests. That shortcut lets an autonomous task delete pods or read secret keys across every namespace. Scoping the role before the agent runs stops accidental changes to your live cluster.

How crewai kubernetes read only access works in native RBAC

Kubernetes controls cluster actions through role-based rules in its native authorization API group. Every rule in this system is additive, which means there are no deny rules. You start with zero rights and add only the read verbs your agent needs. A standard Role sets these read rules inside one specific namespace. If your CrewAI agent must check nodes or pods across all namespaces, you use a ClusterRole instead.

Once you define the read rules, you attach them to the agent identity. A RoleBinding grants those permissions inside a single namespace. A ClusterRoleBinding grants the permissions across the whole cluster. You can bind a ClusterRole with a normal RoleBinding to keep the rule set in one namespace. Your CrewAI tools then use that bound identity to call the cluster API and inspect workloads.

Many debugging agents also need to read container output to find app errors. In Kubernetes RBAC, pod logs are a subresource rather than a top-level object. You must grant read permissions on both the pod resource and the pod log subresource. Without that subresource rule, the agent can list pods but cannot read their log output.

Where native cluster roles fall short for AI agents

Native RBAC decides which API endpoints an identity can call after login. It does not inspect the content returned to the agent during a session. A read rule on a namespace often includes permission to read config maps or secret objects. If a role allows reading secrets, the agent pulls raw keys into its context window. Even pod logs can contain customer emails, phone numbers, or card numbers from app errors.

Static credentials also create a heavy task for your platform team. You have to distribute credentials to the host where the CrewAI process runs. If a developer copies that key to a laptop, the key works until someone revokes it. Native RBAC logs show the service account name, not which human started the CrewAI run. Also, RBAC cannot pause a single risky request for human review while allowing normal reads.

Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Scoping agent permissions by namespace and subresource

To keep native permissions tight, create a dedicated service account just for your CrewAI tasks. Avoid using the default service account in a namespace because other pods share it. Write a Role that lists only the exact resources the agent must check, such as pods and deployments. Leave secret objects out of the rule list so the agent cannot fetch stored keys.

Next, bind that Role to the agent service account inside one target namespace. If the agent checks multiple namespaces, create separate RoleBindings in each allowed namespace. Avoid ClusterRoleBindings unless the agent truly needs to inspect cluster-wide objects like nodes. Finally, check that your rule list excludes write verbs and exec subresources so the agent cannot run commands inside containers.

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 I add a deny rule to block a CrewAI agent from reading secrets?

No, Kubernetes RBAC permissions are strictly additive and do not support deny rules. To block secret reads, you must leave secrets out of every Role bound to the agent.

How do I let a CrewAI agent read pod logs without giving full pod control?

Grant read verbs on the pods resource and the pods log subresource inside your Role. Do not include the pods exec subresource or any write verbs in that rule set.

Should I use a RoleBinding or a ClusterRoleBinding for a CrewAI worker?

Use a RoleBinding whenever possible because it limits the agent to a single namespace. You can still reference a shared read-only ClusterRole inside a namespace-scoped RoleBinding.

The query runs. The emails stay hidden.