Hosting Kubernetes

Published
Length
3 min read

Luis Felipe Dias

All posts

You start hosting kubernetes by setting up an API server and worker nodes. Then you add role rules to control who can run commands on the cluster. Many teams begin by giving broad cluster roles to their engineers. This speeds up early setup work. Yet wide permissions create big risks when an engineer runs a bad command. One mistake can delete live pods or expose secret keys across every namespace. How native permissions work when hosting kubernetes The cluster API server checks every request

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 start hosting kubernetes by setting up an API server and worker nodes. Then you add role rules to control who can run commands on the cluster. Many teams begin by giving broad cluster roles to their engineers. This speeds up early setup work. Yet wide permissions create big risks when an engineer runs a bad command. One mistake can delete live pods or expose secret keys across every namespace.

How native permissions work when hosting kubernetes

The cluster API server checks every request through role-based access control. This system uses four main objects to manage permissions. A Role sets rules inside one single namespace. A ClusterRole sets rules across the whole cluster. It can cover cluster-wide items like nodes or namespaced items across all spaces. All rules in this system are additive. There are no deny rules in native cluster permissions.

Once you write the rules, you must link them to users. A RoleBinding grants permissions to a user or group inside one namespace. It can point to a Role in that same namespace. A RoleBinding can also point to a global ClusterRole to keep rules consistent. A ClusterRoleBinding grants permissions across the entire cluster at once. Teams must use ClusterRoleBindings with great care.

Permissions also cover subresources like pod logs and pod command execution. The API names these items by adding a slash after the main resource. If a role allows pod execution, a user can open a shell inside a container. That user can then run commands as the container process.

What native cluster roles solve and what they miss

Native roles are great for sorting permissions by namespace and resource type. You can let a team read pod logs in one space. At the same time, you can block them from changing node settings. This stops unauthorized users from calling restricted API paths.

Still, native roles only check the initial API call. They decide who can start a session, not what happens inside it. Once an engineer opens a pod shell, the API server stops checking individual commands. The native setup does not inspect the text output returning from that pod. If a log line or shell command prints customer emails or card numbers, raw data flows back. Native roles also force teams to maintain static role bindings that often stay active too long.

Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Steps to tighten cluster permissions in production

First, remove broad cluster-wide bindings from human users. Give engineers standard RoleBindings inside the specific namespaces they manage each day. Use a shared ClusterRole with a local RoleBinding to avoid writing duplicate rules.

Second, split read rules from write and shell rules. Let engineers view pod status and logs by default. Hold back pod shell permissions until a real incident happens. This cuts down the chance of an accidental change during a routine check.

Add request guardrails and response masking beside Kubernetes

Cluster roles and service accounts govern who reaches the Kubernetes API. Still, a broad role or agent can delete workloads or print sensitive values from ConfigMaps and logs. In practice, hoop.dev runs beside the API server as a sidecar for your Kubernetes API and checks every request and response alongside RBAC.

With hoop.dev Kubernetes controls, guardrails can allow listing Secret names while refusing reads of Secret data before execution. Data masking redacts matched keys in returned JSON responses and log streams in memory. Furthermore, hoop.dev holds SOC 2 Type II and is MIT licensed on GitHub.

Frequently asked questions

Can I write a deny rule in native Kubernetes RBAC?

No, native permissions are purely additive. Every user starts with zero permissions, and each binding only adds allowed actions. To block an action, you must remove the rule or binding that grants it.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding applies permissions inside one specific namespace only. A ClusterRoleBinding applies permissions across all namespaces and cluster-scoped resources like nodes. You can pair a RoleBinding with a ClusterRole to limit global rules to one namespace.

Why are pod execution permissions risky in production?

Pod execution rules let a user run an interactive shell inside a live container. From that shell, the user can read local files, inspect memory, or reach internal services. Native RBAC does not filter the commands run inside that shell.

The query runs. The emails stay hidden.