How to Configure Kubernetes Admission Controller
You set up a kubernetes admission controller by turning on plugin rules on your API server. These rules check, change, or block API requests after a user logs in and passes role checks. Teams often start by setting up basic role rules for their cluster users. When those role rules are too broad, users can create bad pods or run risky commands. How a kubernetes admission controller works with cluster roles Every request to a cluster goes through a clear set of steps on the API server. First, t
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 a kubernetes admission controller by turning on plugin rules on your API server. These rules check, change, or block API requests after a user logs in and passes role checks. Teams often start by setting up basic role rules for their cluster users. When those role rules are too broad, users can create bad pods or run risky commands.
How a kubernetes admission controller works with cluster roles
Every request to a cluster goes through a clear set of steps on the API server. First, the server checks who sent the request. Second, role-based access control checks if that user has the right role permissions. In Kubernetes, a Role sets permissions inside one namespace. A ClusterRole sets permissions across the whole cluster, including nodes and all namespaces.
A RoleBinding connects a user to a Role inside one single namespace. A ClusterRoleBinding gives a user those permissions across the entire cluster. All of these role rules are additive, which means there are no deny rules. Once a user passes these role checks, the request reaches the admission phase.
This is where your controller plugins run. Some plugins are built into the API server, while others call out to external webhooks. Mutating plugins can change the request object to add default limits or labels. Validating plugins check the final object against your security rules and reject bad setups. If any plugin says no, the API server stops the request right away.
Why role rules and admission checks still leave gaps
Admission checks are great for stopping bad pod specs before they start running. They make sure new workloads follow your team rules for images, labels, and resource limits. Still, admission checks only inspect the API request at the moment it hits the server. They do not watch what happens inside a shell session after the request passes.
For example, Kubernetes treats pod logs and pod exec sessions as subresources in the API. Role rules refer to these subresources with a slash in the resource name. A team might grant a developer permission to use the exec subresource to fix a broken app. An admission plugin can see that the user wants to start an exec session. It can check who the user is and which pod they want to enter.
K8s Admission Controllers + Kubernetes RBAC: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Once the API server approves that exec request, the user gets an open stream into the container. Neither role bindings nor admission plugins see the shell commands typed inside that stream. They also do not filter the data that comes back on the screen. If a container holds database keys or customer emails, the user can read them in full. Native controls decide who starts a session, not what individual commands do in flight.
Practical steps to plan your admission rules
Start by listing the exact risks you want to block at the API level. Keep your Role and ClusterRole bindings tight so users only touch the namespaces they need. Use built-in admission plugins first before you build or deploy custom webhook servers. Built-in plugins run fast because they live inside the API server process.
When you add webhook plugins, test them in a staging cluster first. If a webhook server goes down, it can block normal pod updates across your cluster. Keep webhook rules focused on pod specs and object settings. For live interactive sessions like pod exec, pair your cluster checks with command-level controls.
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
Does a kubernetes admission controller replace role-based access control?
No, they work together in sequence on the API server. Role rules check if a user can perform an action, and admission plugins inspect the object details.
Can role bindings deny specific users from using pod exec?
No, Kubernetes role permissions are purely additive and never include deny rules. You must leave the exec subresource out of a user role to block it.
Do admission plugins inspect commands typed inside an active exec shell?
No, an admission plugin only sees the initial API request that starts the exec call. It cannot read or block the shell commands that run after the stream opens.
Related guides
In this post