How to Configure Kubernetes Pod Security
You set up kubernetes pod security by creating RBAC roles and bindings that restrict pod actions. You also limit subresource rules like pod logs and remote command execution to specific namespaces. Most engineering teams start by granting broad cluster roles so developers can fix broken apps fast. When those roles stay too wide, any user can run commands inside live containers and read sensitive data. How native kubernetes pod security works with RBAC Native cluster control relies on Role-Bas
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 pod security by creating RBAC roles and bindings that restrict pod actions. You also limit subresource rules like pod logs and remote command execution to specific namespaces. Most engineering teams start by granting broad cluster roles so developers can fix broken apps fast. When those roles stay too wide, any user can run commands inside live containers and read sensitive data.
How native kubernetes pod security works with RBAC
Native cluster control relies on Role-Based Access Control on the API server. In this model, a Role or ClusterRole holds a list of permission rules. These rules are additive, which means there are no deny rules in the system. You start with zero access and add only the actions a user needs.
A Role always sets permissions inside a single namespace. A ClusterRole is not tied to one namespace. It can cover cluster-wide objects like nodes or apply to resources across every namespace. To give those permissions to a user or group, you create a binding.
A RoleBinding grants permissions inside one namespace. It can point to a Role in that same namespace or to a global ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once. Teams that want strong pod isolation prefer RoleBindings over ClusterRoleBindings for daily developer work.
You also have to control subresources to lock down pods. The API server treats actions like reading pod logs or running a shell as subresources. In RBAC rules, you write these with a slash, such as the pod log or pod exec subresource. Separating base pod viewing from exec rules stops users from opening shells in production containers.
Where native roles fall short during live sessions
Native RBAC does a good job deciding who can talk to the API server. It blocks unauthorized users from listing pods or starting an exec session in the wrong namespace. Still, RBAC only checks permissions when the request hits the API server.
Once a role allows a user to run pod exec, native RBAC steps out of the way. It cannot see or restrict which shell commands the engineer runs inside the container. A user who needs to check one local file gets full shell control as the container user.
K8s Pod Security Standards + Kubernetes Operator for Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Subresource rules also have limits when you try to target specific pods. The resource names filter does not block create requests on subresources in standard RBAC workflows. If a developer has exec rights in a namespace, they can often exec into every pod there.
Static roles also stay active until an admin removes the binding by hand. Teams end up leaving powerful bindings in place just in case an outage happens at night. Also, raw container output can print customer emails, phone numbers, card numbers, or national IDs straight to the screen.
Closing the gap for runtime pod actions
To keep production pods safe, teams need controls that work after the initial role check passes. Instead of giving developers standing bindings for pod exec, you can require approval per task. That way, a developer asks for shell rights only when a live incident starts.
Youalso want visibility into every command run inside a container. Standard API server logs show that an exec call started, but they miss the shell activity inside. Adding runtime command checks and data masking rewrites matched fields like emails or card numbers in results.
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 sits inline as an open-source proxy, a sidecar for your Kubernetes API, without replacing RBAC. On every production call from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails refuse banned methods, paths, or headers before they run or hold risky deletes for review. 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 I write a deny rule in Kubernetes RBAC to block pod exec?
No, native RBAC permissions are additive and do not support deny rules. To block pod exec, you must leave that subresource out of every Role and ClusterRole bound to the user.
What is the difference between a RoleBinding and a ClusterRoleBinding for pods?
A RoleBinding grants pod permissions inside one specific namespace only. A ClusterRoleBinding grants those permissions across every namespace in the entire cluster at the same time.
How do I let developers read pod logs without giving them shell access?
You grant access to the pod log subresource in their Role while leaving out the pod exec subresource. This lets users read container output without running interactive commands inside the pod.
Related guides
In this post