Self Managed Kubernetes Cluster
You secure a self managed kubernetes cluster by turning on role-based access control on the API server. Next, you bind narrow roles to each team instead of sharing admin keys. Many teams start by giving broad cluster roles to speed up daily work. Over time, those wide permissions let users run risky commands across every namespace. A single mistake during a fix can take down live apps or expose private data. How roles work in a self managed kubernetes cluster Role-based access control runs on
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 secure a self managed kubernetes cluster by turning on role-based access control on the API server. Next, you bind narrow roles to each team instead of sharing admin keys. Many teams start by giving broad cluster roles to speed up daily work. Over time, those wide permissions let users run risky commands across every namespace. A single mistake during a fix can take down live apps or expose private data.
How roles work in a self managed kubernetes cluster
Role-based access control runs on the API server to check every user request. Rules in this system only add permissions, and there are no deny rules. You start with zero rights and add only what each person needs. A standard role sets permissions inside a single namespace for one specific team. A cluster role covers the whole cluster, including nodes and resources in all namespaces.
After you write a role, you must attach it to a user or group. A role binding gives permissions inside one namespace by linking to a role. A role binding can also reference a cluster role to keep rules in one place. Still, that role binding only grants rights inside its own namespace. A cluster role binding grants permissions across the entire cluster at once.
Some API actions target a subresource, such as reading pod logs or running commands. The permission rule names both the main resource and the subresource with a slash. When you grant pod exec rights, the user can open a shell inside containers. You must scope these bindings with care so teams only touch their own pods.
What native roles solve and what they miss
Native roles and bindings do a great job of controlling who can log in. They let you divide a cluster by namespace so teams stay in their lanes. You can let developers read pod logs without letting them delete live workloads. You can also restrict cluster-wide changes to a small group of platform admins.
Still, native access control only checks the initial API request at the door. Once a role allows pod exec, the cluster stops checking what happens inside. The API server knows a user opened a shell, not which commands they ran. If an engineer inspects a container, they might read raw emails or card numbers. Native roles cannot rewrite matched fields in results when someone queries a pod.
Self-Service Access Portals + Kubernetes RBAC: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Also, static role bindings stay active until an admin removes them by hand. Teams often grant temporary exec rights during an outage and forget to revoke them. Because rules are additive, piling on roles makes it hard to track real access. You need controls that inspect live commands and mask sensitive fields like phone numbers.
Managing day-to-day cluster operations safely
Good cluster hygiene starts with reviewing your role bindings on a set schedule. Avoid using cluster role bindings unless a user truly manages nodes or global objects. Give most engineers namespace-scoped role bindings so an error stays in one area. Split read roles from write roles so daily checks never risk changing a pod.
Pay close attention to subresources that grant shell sessions or log views. Reading pod logs can expose national IDs or emails printed by an app. Opening a shell lets a user run any binary installed inside that container image. Keep these rights out of default developer roles and require approval for live fixes.
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 HTTP proxy, a sidecar for your Kubernetes API. The kubectl client changes only the server address it talks to while RBAC stays in place.
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. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs. Every request and verdict is logged without storing bearer tokens. View the project on GitHub.
Frequently asked questions
Can I write a rule to deny access to one specific pod?
No, permissions in Kubernetes role-based access control are purely additive. You cannot write a deny rule, so you must build small roles from scratch.
What is the difference between a role binding and a cluster role binding?
A role binding grants permissions inside one namespace only. A cluster role binding grants permissions across all namespaces and cluster-wide nodes.
Why is granting pod exec permission risky for production workloads?
Once a user starts an exec session, native roles do not check individual commands. The user can run any script or view sensitive data inside that container.
Related guides
In this post