Kubernetes Security Model
The kubernetes security model uses role-based rules to control who can touch cluster resources. You set up roles and bind them to users or groups to grant permissions. Most teams start by creating broad cluster roles so builders can ship apps fast. When those roles stay too wide, one mistake can break live workloads or expose secrets. How the kubernetes security model works with roles and bindings Every request to a cluster goes through the API server first. The API server checks who sent the
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.
The kubernetes security model uses role-based rules to control who can touch cluster resources. You set up roles and bind them to users or groups to grant permissions. Most teams start by creating broad cluster roles so builders can ship apps fast. When those roles stay too wide, one mistake can break live workloads or expose secrets.
How the kubernetes security model works with roles and bindings
Every request to a cluster goes through the API server first. The API server checks who sent the request and what they want to do. In the kubernetes security model, role-based access control uses four main objects. These objects are Role, ClusterRole, RoleBinding, and ClusterRoleBinding.
A Role holds a list of rules that apply inside one single namespace. A ClusterRole holds rules that are not tied to one single namespace. It can cover cluster-wide items like nodes, or resources across all namespaces at once. It can also cover endpoints that are not tied to standard cluster resources.
Rules in both role types are purely additive, which means there are no deny rules. You start with zero permissions and add only the actions a person or app needs. To grant those permissions, you create a binding object that links a user to a role.
A RoleBinding gives permissions inside one namespace by linking to a Role or a ClusterRole. Putting a ClusterRole in a RoleBinding applies those common rules to just that one namespace. A ClusterRoleBinding grants the permissions inside a ClusterRole across the whole cluster at once.
The API server also uses subresources for actions like reading pod logs or running commands. In your rules, you write the main resource and the subresource with a slash between them. This lets you grant log reading without granting full pod changes.
Where native cluster roles stop and live command risks begin
Native roles and bindings are great for deciding who can reach the API server. They let you split teams by namespace and restrict who can delete pods or nodes. You can also separate read-only viewers from people who deploy new app versions.
Model Context Protocol (MCP) Security + Kubernetes Operator for Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, native access rules only check the start of an API call. Once a user has permission to run commands in a pod, the role check finishes. The cluster does not inspect the shell commands that run inside that open container session.
If an engineer opens a shell into a pod, they can run any command inside it. They can read local files, inspect memory, or pull database keys stored in the pod. They can also query connected stores and view raw emails, phone numbers, or card numbers.
In the same way, granting permission to read secret objects gives back the whole secret. Native rules cannot rewrite matched fields in results to hide national IDs or card numbers. They also cannot pause a single risky shell command while letting safe read commands pass.
Teams often try to fix this by taking away shell and secret permissions from everyone. Then when an app breaks at night, nobody can check the live pod to fix it. Admins end up granting wide cluster bindings in a rush and forgetting to remove them later.
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 runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.
First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. 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 one specific action?
No, permissions in this system are purely additive and do not support deny rules. To block an action, you must leave it out of the roles bound to that user.
What is the difference between a RoleBinding and a ClusterRoleBinding?
A RoleBinding grants permissions inside one specific namespace only. A ClusterRoleBinding grants permissions across the entire cluster and all of its namespaces.
How do I let a team read pod logs without letting them run pod commands?
You grant permission on the pod log subresource in their role rules. Leave the pod exec subresource out of the role so they cannot open a shell.
Related guides
In this post