How to Configure Kubernetes Multi Tenant

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a kubernetes multi tenant cluster by giving each team its own namespace. Then you bind strict role rules to each namespace so teams stay isolated. Many engineering groups start by sharing one large cluster to save money and time. Still, broad permissions let one team read or change another team's apps by mistake. A clear role setup keeps workloads apart and protects shared cluster data. How native kubernetes multi tenant role setup works Role-based access control is the core way to

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 multi tenant cluster by giving each team its own namespace. Then you bind strict role rules to each namespace so teams stay isolated. Many engineering groups start by sharing one large cluster to save money and time. Still, broad permissions let one team read or change another team's apps by mistake. A clear role setup keeps workloads apart and protects shared cluster data.

How native kubernetes multi tenant role setup works

Role-based access control is the core way to split up a shared cluster. This native system runs on the API server to check every request. Permissions in this system are additive only. There are no deny rules in native role-based access control. You start with zero access and add rules for each team.

A Role sets permissions inside one single namespace. In contrast, a ClusterRole is not tied to one namespace. It can cover cluster-wide items like nodes, or resources across all namespaces. To grant these permissions to a user, you create a binding object.

A RoleBinding grants permissions inside one specific namespace. It can point to a Role in that same namespace. A RoleBinding can also point to a shared ClusterRole. When you pair a ClusterRole with a RoleBinding, the user only gets access inside that one namespace. This pattern lets admins write one standard rule set and reuse it for many tenants. By contrast, a ClusterRoleBinding grants access across the whole cluster. You should avoid ClusterRoleBindings for standard tenant users so they stay in their own lane.

How subresources affect tenant isolation

In a shared cluster, you also need to control subresources. The API server names resources using the exact words from the API URL. Some API calls target a subresource, such as reading pod logs or running a shell inside a pod. In your role rules, you write a subresource with a slash between the resource and the action.

Giving a tenant permission to read pods is different from letting them read pod logs. Even more important is the subresource that lets users run commands inside a running pod. If a user has permission for the pod execution subresource, they can open a shell inside that container. Admins must grant these subresource rules with care in a shared cluster.

Kubernetes RBAC + Multi-Factor Authentication (MFA): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native roles and bindings solve the first part of sharing a cluster. They decide which user can call which API endpoint inside a specific namespace. If a developer from Team A tries to list pods in Team B's namespace, the API server blocks the call. This boundary stops cross-tenant mistakes at the API level.

Still, native role rules stop checking once the API call is allowed. The native setup decides who logs in and which pod they can reach. It does not check what individual commands or queries do in flight. Once a developer opens an interactive shell in an allowed pod, native RBAC does not inspect the shell commands they run.

The same gap appears when a user reads pod logs or queries a data store inside their namespace. Native roles cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs inside those results. Also, you cannot require a peer to approve a single risky command right before it runs. Teams that need command-level checks and field masking must look beyond native cluster roles.

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 sits inline beside the API server as a sidecar for your Kubernetes API. For every production API call an agent or human sends, hoop.dev decides whether to pass, mask, block, or escalate it for review alongside RBAC.

With hoop.dev Kubernetes controls, guardrails allow listing Secret names while refusing reads of Secret data before execution, and 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 a kubernetes multi tenant setup?

No, native role permissions are additive only and do not support deny rules. You must start with no permissions and grant only the exact rules each tenant needs.

How can I reuse one role across many tenant namespaces?

Define your common permission rules once inside a ClusterRole object. Then create a separate RoleBinding in each tenant namespace that points to that ClusterRole.

Does blocking pod creation also block users from running commands in existing pods?

No, running commands in a pod uses a separate subresource rule in the API. You must leave out the pod execution subresource permission if you want to block shell access.

The query runs. The emails stay hidden.