How to Configure Kubernetes Read Only Access
You set up kubernetes read only access by binding a role with read rules. This role lets users view cluster objects without making changes. Teams often create these roles so developers can check running pods and read logs. When teams grant broad permissions by mistake, users can change live workloads or read secrets. How kubernetes read only access works in native RBAC Kubernetes controls permissions through its built-in role-based system on the API server. You define rules inside a Role or a
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 kubernetes read only access by binding a role with read rules. This role lets users view cluster objects without making changes. Teams often create these roles so developers can check running pods and read logs. When teams grant broad permissions by mistake, users can change live workloads or read secrets.
How kubernetes read only access works in native RBAC
Kubernetes controls permissions through its built-in role-based system on the API server. You define rules inside a Role or a ClusterRole object. These rules are only additive, which means there are no deny rules at all. If you want a read-only setup, you only list safe viewing actions.
A Role always sets permissions inside one single namespace. A ClusterRole is not tied to one namespace and covers the whole cluster. It can cover cluster-wide objects like nodes or namespaced objects across all namespaces.
After you create a role, you must attach it to a user or group. A RoleBinding grants those permissions inside one specific namespace. That RoleBinding can point to a local Role or a shared ClusterRole. A ClusterRoleBinding grants the permissions across the entire cluster at once.
You also have to watch how rules handle subresources in the API. Kubernetes names resources just like they appear in the API URL path. Some APIs use a subresource, such as a pod log stream. In RBAC rules, you write the resource and subresource with a slash between them. A read-only role often needs permission on the pods log subresource so developers can debug apps.
What native read-only roles solve and what they miss
Native roles are great for stopping accidental edits or deletions in a cluster. A developer with a viewing role cannot delete a pod or change a deployment. This setup decides who can ask the API server for object data.
Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, static roles leave big operational gaps open during daily work. First, a broad viewing role across a namespace often includes secret objects. If a user can read secrets, they can see database keys and API tokens. Because RBAC has no deny rules, you cannot easily block one resource from a wildcard rule.
Second, pod logs and config files often hold sensitive user data. When an engineer reads a pod log, the API server sends the raw text back. Native Kubernetes roles do not check what is inside that text stream. Phone numbers, emails, and card numbers show up in plain text on the screen.
Third, teams still have to hand out cluster credentials and config files to users. Managing these files across many clusters takes a lot of time for platform teams. And when an engineer needs to run a single fix, static read roles block them. Teams end up handing out broad admin roles during an incident and forgetting to revoke them.
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 proxy, a sidecar for your Kubernetes API, inline on the API connection. On every kubectl or API call an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
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, or hold risky calls for approval. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs in memory. View the project on GitHub.
Frequently asked questions
What is the difference between a Role and a ClusterRole for viewing resources?
A Role applies only to a single namespace that you pick. A ClusterRole can apply to cluster-wide objects like nodes or across all namespaces at once. You can pair a ClusterRole with a RoleBinding to limit viewing to one namespace.
Can I add a deny rule to block secrets in a read-only role?
No, Kubernetes RBAC rules are only additive and do not support deny rules. To block secrets, you must list every allowed resource by name in your role. You must leave the secrets resource out of that list.
How do I let users read pod logs without letting them run commands?
Kubernetes treats pod logs and pod command execution as separate subresources in the API. You grant read permission on the pods log subresource in your role rules. You leave out the pods exec subresource so users cannot open a shell.
Related guides
In this post