Self Host Kubernetes
To self host kubernetes, you deploy the control plane and worker nodes on your own machines. You then set up role-based rules on the API server to control user actions. Teams often start by handing out broad admin roles so builders can ship fast. When permissions stay too wide, one bad command can break live apps or expose private data. How to self host kubernetes with native role rules When you run your own cluster, the API server checks every request. You control these checks by turning 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.
To self host kubernetes, you deploy the control plane and worker nodes on your own machines. You then set up role-based rules on the API server to control user actions. Teams often start by handing out broad admin roles so builders can ship fast. When permissions stay too wide, one bad command can break live apps or expose private data.
How to self host kubernetes with native role rules
When you run your own cluster, the API server checks every request. You control these checks by turning on role-based access control. In this system, rules are purely additive. There are no deny rules at all. You build a role by listing the exact actions a person or app can take.
Kubernetes splits these rules into two levels. A standard role sets permissions inside one single namespace. A cluster role works across the whole cluster. It can cover cluster-wide items like nodes, or resources across every namespace at once.
After you write a role, you must bind it to a user or group. A role binding grants permissions inside one namespace. It can point to a standard role or a shared cluster role. A cluster role binding grants permissions across the entire cluster at once.
The API server also uses subresources for specific actions on a pod. For example, reading pod logs or running a shell inside a pod uses subresources. You must list these subresources in your role rules if engineers need them to fix bugs.
What native cluster roles solve and what they miss
Native role bindings do a great job of deciding who can reach the API server. They let you lock down namespaces so teams only see their own apps. You can give read-only rules to most staff and keep write rules for a few leads.
Still, native roles leave a big gap during daily work. A role binding decides who can open a shell on a pod. It does not check what commands that person runs inside the shell. Once the session starts, the cluster cannot stop a bad script from dropping files.
Self-Service Access Portals + Kubernetes RBAC: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Native rules also cannot inspect or change the data that flows back to the user. If an engineer reads pod logs or queries a pod, raw data comes back on screen. Native roles cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs in those results.
Audit logs on the API server record that a user started a pod shell. Yet they do not show the full interactive output or block risky shell commands in flight. Teams must pair native roles with finer controls over live commands and data output.
Planning day-two operations for your cluster
Running your own nodes means you own every part of the lifecycle. You must plan how to rotate client keys and update the control plane without downtime. Many teams link the API server to an external identity provider so staff log in with work accounts.
Even with external login, you still map groups to cluster roles. Keep cluster role bindings rare and review them every month. When someone needs to fix a live pod, grant the smallest role needed for that one namespace. Remove that binding as soon as the fix is done.
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 deny rule in Kubernetes RBAC?
No, Kubernetes role rules are purely additive and never support deny rules. To block an action, you must remove the role binding that grants that permission.
What is the difference between a role and a cluster role?
A role applies only to resources inside one specific namespace. A cluster role can apply to cluster-wide items like nodes or to resources across all namespaces.
How does Kubernetes control shell access to a pod?
The API server treats pod shell execution and pod logs as subresources. You must grant explicit permissions for those subresources inside a role before a user can run commands.
Related guides
In this post