Namespace-Based Multi-Tenancy Limits in Kubernetes

Namespace-Based Multi-Tenancy Limits in Kubernetes

How one shared cluster can serve many teams or customers, which limits you can set on each namespace, and, just as important, where a namespace stops protecting you and other layers must take over.

Imagine a large office building shared by many companies. Each company gets its own floor, with its own door, its own meeting rooms and its own cleaning budget. The building manager caps how much electricity each floor may use, and how many desks each company may place. That arrangement is efficient, because the lifts, the lobby and the power supply are shared. But a floor number on a door is not a vault. If the walls are thin, the air ducts are shared or the master key is lost, one company can still disturb or peek into another. Kubernetes namespaces are the floors of this building, and the limits you set on them are the electricity caps and desk counts.

This post teaches namespace-based multi-tenancy from the beginning. You do not need to be a security specialist. We start with why teams share clusters at all, then explain what a namespace really is, and then walk through each limit and guard you can attach to it: quotas, default sizes, access rules, network rules, security profiles and node placement. Just as important, we show what namespaces cannot do on their own, so that you design for the real threats instead of the imagined ones. Every term is defined, compared with something from daily life, and used again in the next section.

1Why Teams Share a Cluster in the First Place

Start with the economics and the operating pressures that make multi-tenancy attractive, and risky.

The cost of one cluster per team

The cleanest way to keep teams apart is to give each one its own cluster. Nobody can disturb anybody, and mistakes are contained. But every cluster carries a fixed overhead: control plane machines, monitoring, logging, certificates, upgrades, security patching and people to run it all. With dozens of teams this becomes expensive and slow, and many clusters end up half empty, because each is sized for its peak.

Simple Analogy

Giving every company its own entire building is safe, but most of those buildings stand mostly empty and each needs its own lifts, guards and power station. Sharing one building divides those fixed costs, as long as the rules for sharing are clear.

What sharing buys

Benefit 1

Better utilisation

Spare capacity left by one team can be used by another, so fewer machines sit idle.

Benefit 2

Lower operating effort

One control plane to upgrade, secure and monitor instead of dozens.

Benefit 3

Faster onboarding

A new team gets a namespace in minutes, not a cluster in days.

Benefit 4

Shared platform services

Ingress, monitoring, certificates and policy engines are installed once and used by all.

What sharing risks

Sharing creates three kinds of risk. Noisy neighbours are tenants that consume so much that others suffer. Snooping and tampering are tenants that read or change what belongs to others. Shared failure is when one tenant’s mistake, such as flooding the API server, harms everyone. A well-designed multi-tenant cluster limits all three risks, and the namespace is only the first of several tools.

!
Common Misconception

Many beginners believe that creating a namespace for each team gives them isolation. A namespace on its own is mostly a naming and grouping boundary. Isolation only appears when you attach limits, access rules and policies to it. The rest of this post is about those attachments.

2What a Namespace Is, and What It Is Not

Get the definition exactly right, because every design decision depends on it.

The definition

A namespace is a named scope inside a cluster. Most Kubernetes objects, such as Pods, Services, ConfigMaps, Secrets and Deployments, live inside exactly one namespace. Names only need to be unique within their namespace, so two teams can both have a Service called “web” without any clash. Many access rules and limits are attached to a namespace, which makes it the natural unit for handing out slices of a cluster.

Simple Analogy

A namespace is like a folder on a shared drive. Two folders can both contain a file called “report” without conflict. Folders also let you set access and size rules per folder. But the folders all sit on the same disk, run on the same computer and are managed by the same administrator.

What lives outside any namespace

Some objects are cluster-scoped. They belong to the whole cluster and cannot be placed in a namespace. This list is the main reason a namespace is not a complete boundary.

Cluster-scoped

Nodes

The machines themselves. All tenants’ Pods run on the same pool of nodes unless you separate them.

Cluster-scoped

PersistentVolumes and StorageClasses

Volumes and storage menus are shared across the cluster, even though claims are namespaced.

Cluster-scoped

CustomResourceDefinitions

New object types are added for the whole cluster. One tenant installing a definition affects everyone.

Cluster-scoped

ClusterRoles and bindings

Cluster-wide permissions. A single careless binding can grant power across all namespaces.

Cluster-scoped

Admission webhooks and priority classes

Global rules and global importance levels that apply to every tenant’s workloads.

Cluster-scoped

Namespaces themselves

Creating or deleting namespaces is a cluster-level power that tenants should not hold freely.

What a namespace does not give you

No automatic network isolation

By default, a Pod in one namespace can send traffic to any Pod or Service in any other namespace, using its address or its cluster DNS name.

No automatic resource limits

A new namespace has no cap on CPU, memory, storage or object count. One tenant can consume everything unless limits are added.

No separate kernel

Containers from different namespaces on the same node share the node’s operating system kernel. A flaw that lets a container escape its sandbox exposes the neighbours on that node.

No separate control plane

All tenants talk to the same API server and the same database. A burst of requests from one tenant can slow everyone.

i
The Right Mental Model

Think of a namespace as a place to hang policies, not as a wall. The wall is built from the policies you attach: quotas, access rules, network rules, security profiles and node placement. Remove the policies and the namespace is just a label.

3Tenancy Models and Threat Models

Before choosing any limit, decide who your tenants are and how much you trust them.

Who is a tenant?

A tenant is a group that uses a share of the cluster and should be kept somewhat apart from other groups. It might be a team in one company, a department, a project, a customer of a software service, or an environment such as testing. The right amount of isolation depends on who they are.

Soft and hard multi-tenancy

Soft multi-tenancy assumes tenants are friendly: different teams in the same organisation who share goals and can be held accountable. The aim is mostly to prevent accidents, such as one team using up all the memory or editing another team’s Deployment by mistake. Hard multi-tenancy assumes tenants may be hostile or run untrusted code: customers of a hosting platform, for example. The aim is to withstand deliberate attacks. Namespaces plus policies are a reasonable foundation for soft multi-tenancy. For hard multi-tenancy they are necessary but usually not sufficient.

Simple Analogy

Soft multi-tenancy is like colleagues from different teams sharing an office floor: you need name labels, desk limits and polite rules. Hard multi-tenancy is like different companies sharing a building where one might be a competitor: you need locked doors, separate air systems and security guards.

The main tenancy models

ModelIsolation strengthCost and effortBest for
Namespace per team or app with policiesModerate, softLowTrusted teams in one organisation
Namespaces plus dedicated node poolsStronger, separates computeMediumTeams with different risk or compliance needs
Namespaces plus sandboxed runtimesStronger, reduces kernel sharingMedium to highRunning less trusted workloads on shared nodes
Virtual clusters inside a shared clusterStrong at the control plane levelMediumTenants that need their own API objects and definitions
Separate cluster per tenantStrongestHighHostile tenants, strict compliance, large customers
flowchart TD
  Q["Who are your tenants?"] --> T{"Do you trust them to run code safely?"}
  T -- "Yes, same organisation" --> S["Namespaces with quotas, access and network rules"]
  T -- "Mostly, but different risk levels" --> N["Add dedicated node pools and stricter security profiles"]
  T -- "Not fully, may run untrusted code" --> R["Add sandboxed runtimes, consider virtual clusters"]
  T -- "No, hostile or regulated" --> C["Use a separate cluster per tenant"]
        
FIG 1 — A simple decision path: the less you trust a tenant, the more layers you add beyond the namespace
!
Be Honest About Your Threat Model

The most expensive mistakes come from using a soft multi-tenancy design for a hard multi-tenancy problem. If tenants can run arbitrary code you do not review, assume a determined tenant will try to break out, and design accordingly.

4The Layered Defence: Six Limits Around One Namespace

A single control never carries the weight. Namespace isolation is a stack of layers, each covering what the others cannot.

The six layers

A well-built tenant namespace combines several kinds of limit. Each answers a different question about what a tenant may do.

Layer 1

How much? Quotas and defaults

Caps on total resources and object counts, plus sensible default sizes for each container.

Layer 2

Who may do what? Access rules

Role-based access control that confines each tenant’s people and programs to their own namespace.

Layer 3

Who may talk to whom? Network rules

Policies that stop traffic between namespaces unless explicitly allowed.

Layer 4

What may a workload do? Security profiles

Rules that stop dangerous Pod settings, such as running as root or mounting host folders.

Layer 5

Where may it run? Node placement

Dedicated nodes and stronger sandboxes so that tenants do not share a machine or a kernel unless you accept that.

Layer 6

How hard may it push the cluster? Control plane limits

Fair queuing for API requests and caps on object counts, so one tenant cannot overload the shared brain.

flowchart TD
  T["Tenant workload"] --> L1["Layer 1: quotas and default sizes"]
  L1 --> L2["Layer 2: access rules"]
  L2 --> L3["Layer 3: network rules"]
  L3 --> L4["Layer 4: Pod security profiles"]
  L4 --> L5["Layer 5: node placement and sandboxes"]
  L5 --> L6["Layer 6: control plane fairness"]
  L6 --> C[("Shared cluster")]
        
FIG 2 — Six layers between a tenant and the shared cluster, each catching what the others miss
Simple Analogy

Think of airport security. There is a ticket check, an identity check, a baggage scan, a body scan and gate control. No single check is perfect, but together they make it hard to cause trouble. Namespace security works the same way: many modest checks stacked together.

The next chapters take each layer in turn, starting with the most visible one: limits on how much a tenant may consume.

5ResourceQuota: A Budget for the Whole Namespace

The main tool for capping how much of the cluster a tenant can claim.

What it is

A ResourceQuota is an object placed in a namespace that sets hard caps on the total amount of resources the whole namespace may use. When someone tries to create something that would push the total over the cap, the request is refused. Think of it as a monthly budget for the whole floor of the building.

Simple Analogy

A quota is the electricity and desk budget the building manager sets for a company. The company can arrange its desks and devices freely, but once the total hits the cap, the manager refuses further requests until something is returned.

What a quota can limit

Compute

CPU and memory requests and limits

The sum of what all Pods in the namespace ask for, and the sum of the ceilings they declare.

Storage

Requested storage

Total storage requested by claims, and also the number of claims. Can be set per storage class, so expensive fast storage can be capped more tightly than cheap storage.

Ephemeral

Temporary local storage

Scratch space used by containers on the node, which can otherwise fill a node’s disk.

Extended

Special devices

Accelerators such as GPUs and other advertised resources, limited by requested amounts.

Counts

Number of objects

How many Pods, Services, Secrets, ConfigMaps, claims and other objects may exist. Generic counting is available for many kinds of object.

Service types

Costly Service kinds

Separate counts for node-port and load-balancer Services, which consume scarce ports and cloud load balancers.

Requests versus limits in a quota

Containers declare two numbers for CPU and memory. The request is what the scheduler reserves, a guaranteed minimum. The limit is the ceiling the container may not exceed. A quota can cap the total of requests, the total of limits, or both. Capping requests controls how much of the cluster’s capacity a tenant can reserve. Capping limits controls how far the tenant can burst. Most platforms cap both, because capping only one leaves a gap.

Scopes: quotas for particular kinds of Pod

A quota can apply only to a subset of Pods by using scopes. For instance, a scope can select long-running Pods separately from short-lived ones, or Pods with no declared sizes from Pods with them, or Pods of a particular priority class. This lets you give a tenant, say, a generous budget for batch Pods and a small budget for high-priority Pods, so that important capacity cannot all be taken by one team.

1

Decide the tenant’s budget

Agree on total CPU, memory, storage and object counts based on the tenant’s needs, cost allocation and cluster capacity.

2

Create the quota in the tenant’s namespace

It starts counting existing usage and refuses any request that would exceed a cap.

3

Users create workloads as usual

Every create or scale request is checked against the remaining budget.

4

Requests that exceed the budget are refused

The user sees a clear message about which resource ran out, and can free resources or ask for more.

!
Quota Does Not Evict Running Work

A quota is checked when something is created or changed. If you lower a quota below current usage, existing Pods keep running. Only new creations are blocked. Quotas are a budget for future requests, not a kill switch for current ones.

6LimitRange: Default Sizes and Per-Object Bounds

A quota caps the total. A LimitRange shapes each individual container, Pod and claim.

What it is

A LimitRange is another namespace-level object. Where a quota controls the namespace total, a LimitRange controls the size of each individual thing. It can set default values for containers that did not declare any, minimum and maximum sizes that each container or Pod may have, and a maximum ratio between a container’s limit and request. It can also bound the size of each storage claim.

Simple Analogy

If the quota is the floor’s total electricity budget, the LimitRange is the rule that every desk gets a standard power strip by default, and no single desk may draw more than a set amount. It stops one huge machine from eating most of the budget alone.

Why quotas and LimitRanges belong together

There is an important interaction. When a namespace has a quota on CPU or memory, every new container in it must declare its size, or the request is rejected, because the system cannot add up an unknown amount. Developers who forget to set sizes would hit confusing errors. A LimitRange with default values fills in sensible sizes automatically, so the quota can do its arithmetic and the developer’s workload is accepted.

SettingWhat it doesWhy it helps
Default limitApplied when a container declares no limitPrevents unbounded containers
Default requestApplied when a container declares no requestLets the scheduler and the quota count the container
MinimumRejects containers asking for less than thisAvoids tiny containers that cannot do useful work
MaximumRejects containers asking for more than thisStops one container from consuming a huge share
Limit-to-request ratioCaps how far a container can burst above its reservationLimits overcommit and noisy bursts
Claim size boundsSets minimum and maximum storage per claimPrevents accidental giant volumes

What it does not do

It applies only to new objects

Changing a LimitRange does not alter Pods that already exist. Only Pods created or updated after the change are checked or defaulted.

It does not cap the namespace total

A thousand small allowed containers can still add up to a very large total. Only the quota stops that, which is why you need both.

Defaults are guesses

A default size is a safe starting point, not the right size for any particular application. Encourage teams to set their own sizes based on measurement.

i
A Good Starter Pairing

For each tenant namespace, create one quota for the totals and one LimitRange for defaults and maximums. Together they cover both the whole and the parts, and they make errors friendlier because workloads without declared sizes still get accepted with sensible defaults.

7How Limits Are Enforced: The Admission Path

Quotas and ranges are checked at one particular moment in a request’s life. Knowing when helps you predict their effects.

The gatekeepers in order

Every request to create or change an object passes through the API server in stages. First the caller is identified, then checked for permission, then the request passes through admission controllers: gatekeepers that can change or reject the request before it is stored. Defaults from a LimitRange are applied early, because they modify the object. Security profile checks and custom policies run as validators. The quota check runs near the end, so that it counts the object in its final form.

sequenceDiagram
  participant U as Tenant user
  participant A as API Server
  participant LR as LimitRange step
  participant PS as Security profile and policy checks
  participant RQ as Quota check
  participant E as Database
  U->>A: Create a Pod in the tenant namespace
  A->>A: Identify caller and check permission
  A->>LR: Fill in default sizes, check min and max
  LR-->>A: Pod now has sizes
  A->>PS: Check Pod settings against security rules
  PS-->>A: Allowed
  A->>RQ: Would the new total exceed the quota?
  RQ-->>A: Within budget, usage updated
  A->>E: Store the Pod
  E-->>U: Pod created
        
FIG 3 — A Pod creation request: permission, defaults, security checks, quota check, then storage

What this order means in practice

Defaults are added before the quota check, so an unsized container passes if the LimitRange gives it a size and the quota has room. A Pod that violates the security profile is rejected before it uses up any of the quota. A request rejected for exceeding the quota gets a clear message that names the resource and the numbers involved, which makes it easy to understand.

Where problems hide: controllers that create Pods

Users rarely create Pods directly. They create Deployments, Jobs and StatefulSets, which in turn create Pods through controllers. If the quota or a policy rejects the Pod, the error does not appear when the user applies the Deployment, since the Deployment itself is accepted. The error appears later, as an event on the controller’s child object, and the Deployment simply shows fewer Pods than wanted. This surprises many people: the apply succeeds, yet nothing runs, and the reason is hidden one level down in events.

Simple Analogy

You hand an order form to a manager, who accepts it. The manager then asks the purchasing clerk to buy the items, and the clerk is refused by the finance office. You were told “order accepted,” but the real refusal happened one step later, and you must ask the clerk to find out why nothing arrived.

i
Where to Look

When a Deployment has fewer Pods than expected, look at the events on its ReplicaSet and on the namespace. Messages about exceeded quota, missing sizes or security profile violations show up there, not on the Deployment itself.

Usage accounting and timing

The system keeps a running tally of used amounts. The tally is updated at admission and reconciled by a controller, so very rapid bursts of requests are checked consistently, but the reported usage may lag by moments. Deleting objects frees the budget after they are fully gone, not the instant a deletion is requested, which matters for Pods that take time to shut down.

8Runtime Behaviour: QoS, Requests, Limits and Noisy Neighbours

Quotas control what you may reserve. What happens when tenants actually use the machines is a separate story.

Requests schedule, limits enforce

A container’s CPU and memory request is used by the scheduler when choosing a node: it reserves that amount on the node. The limit is enforced at runtime by the node. If a container exceeds its memory limit, it is killed. If it exceeds its CPU limit, it is slowed down, a behaviour called throttling. Requests are about fairness at placement time, limits are about protection at run time.

Quality of service classes

Based on how requests and limits are set, every Pod falls into one of three classes. This class decides who suffers first when a node runs short of memory.

Class

Guaranteed

Every container sets requests equal to limits for CPU and memory. These Pods are the last to be evicted under pressure and get predictable performance.

Class

Burstable

Some requests are set, but not equal to limits. They may use more when available but are at moderate risk under pressure.

Class

Best effort

No requests or limits at all. They use leftovers and are the first to be evicted when the node is under pressure.

Simple Analogy

Guaranteed Pods hold reserved seats on a train. Burstable Pods have a reserved seat plus permission to stand in the aisle if there is room. Best effort Pods have no ticket and are asked to leave first when the train gets crowded.

Noisy neighbours on a shared node

Even with quotas, tenants whose Pods share a node can interfere with each other in ways that quotas do not measure. CPU limits protect from CPU overuse, but a tenant can still hammer the disk, saturate the network card, exhaust the number of processes allowed on the node, or fill the node’s temporary storage. These shared resources are harder to partition, and they are a common reason to give sensitive tenants their own nodes.

Disk and network contention

Throughput of local disks and network cards is shared. A tenant running heavy data processing can slow neighbours’ databases, even though both are within their CPU and memory budgets.

Process and file handle exhaustion

A Pod that spawns a huge number of processes can exhaust node-level limits unless a per-Pod process cap is set at the cluster level. Without it, a runaway program can harm unrelated Pods.

Ephemeral storage pressure

Container logs and scratch files live on the node’s disk. A tenant writing lots of local data can trigger evictions of other Pods. Quotas on ephemeral storage and log rotation reduce this risk.

!
Sum of Quotas Versus Real Capacity

A quota is a ceiling, not a reservation. If you give ten tenants quotas that add up to twice your cluster’s real capacity, nothing stops them all from trying to use their full share. Pods then stay pending for lack of nodes. Decide deliberately how much you overcommit, and add capacity planning to your process.

9Access Rules: Role-Based Access Control for Tenants

Quotas stop overuse. Access rules stop snooping and tampering.

The building blocks

Kubernetes uses role-based access control, usually shortened to RBAC. A Role lists permissions, such as “may read and create Pods” within one namespace. A RoleBinding attaches a role to people, groups or program identities, called service accounts, inside that namespace. There are cluster-wide versions of both, called ClusterRole and ClusterRoleBinding, whose effects span every namespace.

Simple Analogy

A Role is a job description: “may open the supply cupboard and book meeting rooms on floor 7.” A RoleBinding is the badge that gives a particular person that job. A ClusterRoleBinding is a master key that opens every floor, so it should be handed out very rarely.

The standard pattern for tenants

1

Map tenant people to groups

Use groups from your identity provider, so that membership changes flow in automatically, not through manual edits.

2

Bind groups to namespace-scoped roles

Give the tenant’s developers a role in their own namespace only, with permissions suited to their work.

3

Reuse a cluster-wide role definition, bound per namespace

Define a standard “tenant developer” role once at the cluster level, and attach it with a namespace-level binding, so the same permissions apply in each tenant namespace without being cluster-wide.

4

Keep cluster-level powers with the platform team

Creating namespaces, quotas, node pools, definitions and cluster roles stays with platform administrators.

Permissions that quietly break isolation

Permission to edit quotas or limit ranges

If tenants can edit their own quota, the cap means nothing. Make these objects editable only by the platform team.

Permission to create roles and bindings

A tenant who can create bindings can grant themselves more power, within the limits Kubernetes imposes against escalation, so keep this ability tightly controlled.

Permission to read Secrets broadly

Secrets hold passwords and tokens. A tenant able to list Secrets in a namespace can read all of them. Give this only where needed, and avoid sharing Secrets across tenants.

Permission to create Pods that use any service account

A user who can create Pods in a namespace can run them under any service account in that namespace, and thus inherit that account’s powers. Keep service accounts minimal.

Wildcard permissions

Roles that grant every verb on every resource are as dangerous in a namespace as in the cluster. Avoid wildcards and list permissions explicitly.

!
Service Accounts Are Identities Too

Programs running in a Pod authenticate using a service account. Each namespace has a default one. Do not grant the default account any real power, create purpose-specific accounts, and turn off automatic token mounting for Pods that do not need to call the API.

10Network Isolation with Network Policies

By default every Pod can talk to every other Pod. Network policies change that default.

The open-by-default network

Out of the box, Kubernetes networking is flat and open. A Pod in one tenant’s namespace can reach Services in any other, using their predictable cluster DNS names. This means a compromised or curious workload can probe and attack neighbours’ services unless the network is restricted.

What a network policy is

A NetworkPolicy is a namespace-level object that describes which traffic is allowed to and from selected Pods. Policies are additive and permissive in nature: once any policy selects a Pod for a direction, only the traffic explicitly allowed for that direction is permitted. They are enforced by the cluster’s network plugin, so a plugin that supports them is required. Without one, the objects exist but have no effect.

Simple Analogy

An open network is a building where every internal door is unlocked. A network policy is a lock on each floor’s door. A default-deny policy locks every door, and then you add specific keys: “the shop floor may call the finance floor’s payment desk, and nothing else.”

The default-deny starting point

The standard approach for tenants is to begin with a policy that denies all incoming traffic to every Pod in the namespace, and often all outgoing traffic too. Then add narrow allow rules for what the tenant truly needs: traffic between its own Pods, access to cluster DNS, access to shared platform services, and access from the ingress layer. Everything else is blocked, including traffic to other tenants.

flowchart LR
  subgraph TA["Namespace: tenant A"]
    A1["Web Pod"] --> A2["API Pod"]
  end
  subgraph TB["Namespace: tenant B"]
    B1["Web Pod"] --> B2["API Pod"]
  end
  A1 -. "blocked by default deny" .-> B2
  B1 -. "blocked by default deny" .-> A2
  ING["Ingress layer"] --> A1
  ING --> B1
  DNS["Cluster DNS"] --- A1
  DNS --- B1
        
FIG 4 — With default deny, each tenant’s Pods talk to their own Pods, to DNS and to the ingress layer, but not to each other

Details that trip people up

Remember to allow DNS

A deny-all egress rule also blocks name lookups. Applications then appear to fail strangely. Allow traffic to the cluster DNS service explicitly.

Policies select Pods by labels

Rules refer to namespaces and Pods by labels. Make sure tenant namespaces carry consistent labels, and control who may change them, because a changed label can change which policy applies.

Policies do not see inside traffic

They work at the level of addresses, ports and protocols. They do not inspect content, and they do not give you encryption. Encryption between Pods needs a separate mechanism.

Shared services need explicit paths

Monitoring, logging and ingress components live in platform namespaces. Write clear allow rules for the traffic they legitimately need, in both directions.

i
Make It Part of the Template

Create the default-deny policy together with the namespace as part of automated tenant setup. A namespace that exists for even a day without it is a namespace where cross-tenant traffic was possible.

11Pod Security Standards and Admission Policies

Stop dangerous workloads at the door, before they ever start.

Why Pod settings matter for isolation

A Pod specification can ask for dangerous powers. It can run as the machine’s administrator, share the node’s network, mount folders from the node’s own disk, or add extra kernel capabilities. A Pod using such settings can read other tenants’ data on the same node, or take over the node. Isolation between namespaces collapses if tenants may use these settings freely.

Pod Security Standards

Kubernetes defines three standard profiles, and a built-in admission feature can enforce them per namespace by reading labels on the namespace.

Profile

Privileged

No restrictions at all. Meant only for trusted system components, never for ordinary tenants.

Profile

Baseline

Blocks the known dangerous settings, such as host networking, host folder mounts and privileged containers, while allowing most ordinary applications.

Profile

Restricted

Follows current hardening practice, such as running as a non-root user and dropping extra capabilities. The right target for most tenant workloads.

Three modes per profile

For each namespace you choose a profile and a mode. Enforce rejects Pods that violate the profile. Audit allows them but records the violation. Warn allows them but shows the user a warning. A common rollout is to start with audit and warn to find out what would break, fix workloads, and then turn on enforce.

Simple Analogy

Pod security profiles are the building’s safety code. Baseline bans the obvious hazards, like blocking fire exits. Restricted adds modern best practice, like requiring sprinklers. Warn mode is a friendly inspection note, audit mode is a quiet record, enforce mode is the fine.

Going beyond the built-in profiles

The standard profiles are broad. Organisations often need finer rules, such as “images must come from our registry,” “every Pod must have an owner label,” “no Service of type load balancer in this namespace,” or “limits must stay under a certain size.” The cluster supports policy engines and built-in declarative validation rules for this. Policy rules can be attached per namespace or per label, and they run at admission, in the same stage as the security profile checks.

Restrict where images come from

Allow only images from approved registries, and ideally require version tags or digests, to keep untrusted code out.

Require labels for ownership and cost

Refuse workloads without team and cost-centre labels, so that every object can be traced to a tenant for billing and incident response.

Block risky object types

Prevent tenants from creating objects that reach outside their namespace, such as certain Service kinds or cluster-scoped references.

Protect critical labels

Stop tenants from changing the labels on their own namespace that policies rely on, such as the tenant name or security profile level.

!
Policies Apply to New and Changed Objects

Admission checks run on create and update. Workloads that already existed before a rule was introduced keep running until they are next changed. Use audit reports to find and fix them, rather than assuming that a new rule has cleaned up the past.

12Node-Level Isolation: Dedicated Nodes and Sandboxed Runtimes

When tenants should not share a machine, or at least not share a kernel.

Why the node is the weak point

All the layers so far work inside the Kubernetes API. But containers from different tenants that land on the same node share that node’s kernel, its disks and its network card. A kernel flaw, a container escape or a resource-hungry neighbour can cross namespace lines at this level. Where the risk is significant, you separate tenants physically or with stronger sandboxes.

Dedicated node pools with taints and labels

You can reserve a group of nodes for a tenant. The nodes get a taint, a marker that repels all Pods except those that carry a matching toleration. They also get a label, and the tenant’s Pods are required to select that label. Together the taint keeps others out and the label keeps the tenant’s Pods in. An admission rule can add the toleration and the selector automatically for every Pod in the tenant’s namespace, so tenants cannot forget or bypass it.

Simple Analogy

A taint is a “staff only” sign on a room. A toleration is the staff badge that lets someone in. The label is the name of the department that must use the room. Without the sign, anyone wanders in. Without the badge rule, a department can ignore its own room.

1

Create a node pool for the tenant

Label the nodes with the tenant’s name and taint them so that ordinary Pods are repelled.

2

Inject the toleration and selector automatically

Use an admission rule scoped to the tenant namespace so every Pod gets them without relying on the developer.

3

Prevent tenants from changing the rules

Block Pods from setting a specific node directly or using another tenant’s label or toleration.

4

Plan the shared system Pods

Per-node agents such as logging and networking must tolerate the taints, or they will not run on dedicated nodes.

Sandboxed runtimes

Another approach is to keep sharing nodes but harden the boundary between containers. A RuntimeClass lets a Pod choose a different container runtime, such as one that runs each Pod inside a lightweight virtual machine or a user-space kernel. These sandboxes put an extra barrier between the container and the node’s kernel, which reduces the impact of a container escape. They cost some performance and compatibility, so they are usually applied to the least trusted workloads, not to everything.

Dedicated node pools

  • Strong separation of CPU, memory, disk and network between tenants
  • Simple to understand and to bill per tenant
  • Removes most noisy-neighbour problems

Costs of dedicated pools

  • Lower overall utilisation, since spare room cannot be shared
  • More pools to manage, upgrade and scale
  • Per-node overhead repeats for each pool
i
Mix and Match

A common pattern is a shared pool for trusted internal teams, dedicated pools for regulated or high-risk tenants, and sandboxed runtimes for workloads that run third-party code. The namespace stays the unit of administration across all of them.

13Protecting the Shared Control Plane

All tenants share one API server and one database. A single noisy tenant can slow them all.

The shared brain

The API server handles every request from every tenant, and the cluster’s database stores every object. Their capacity is finite. A tenant program with a bug that polls or creates objects in a tight loop can swamp the API server, slowing deployments and controllers for everyone. A tenant that stores huge numbers of objects, or very large ones, can bloat the database and slow all reads and writes.

Simple Analogy

The API server is the building’s single reception desk. If one company sends hundreds of messengers at once, everyone else queues behind them. Fair queuing means each company gets its turn at the desk, so no one can monopolise it.

API priority and fairness

The API server includes a fairness system. Requests are classified into flows, for example by user, group or namespace, and assigned to priority levels. Each level has its own share of the server’s capacity and its own queues. When the server is busy, requests from a heavy flow wait in their own queue instead of pushing out other flows. Platform teams can define rules that give each tenant a flow of its own, so that one tenant’s burst only delays that tenant.

Capping object counts

Object count quotas protect the database. Limits on the number of ConfigMaps, Secrets, Pods, Services, Jobs and claims stop runaway automation from creating millions of small objects. Finished Jobs and their Pods can pile up, so counting limits and automatic clean-up settings help keep the database lean.

Control

Request fairness per tenant

Classify each tenant’s callers into their own flow so bursts stay local.

Control

Object count caps

Limit how many objects of each kind a namespace may own, protecting the database.

Control

Automatic clean-up

Expire finished Jobs and old records so they do not accumulate forever.

Control

Limits on watchers and heavy listers

Educate tenants to use efficient list-and-watch patterns, since many clients polling large lists is costly.

Shared extension points

Custom resource definitions

They are cluster-wide. If tenants may install definitions, they can add new object types, conflict with others’ names, and add load. Keep definition installation with the platform team, or use virtual clusters when tenants need their own.

Admission webhooks

Webhooks run on every matching request. A slow or failing webhook can block everyone’s deployments. Scope webhooks narrowly, set short timeouts and decide carefully whether failures should block requests.

Controllers and operators installed by tenants

A controller watching the whole cluster can see objects across tenants. Prefer controllers that watch only specific namespaces, and review any operator before allowing it.

!
Hard Ceiling for Hard Tenants

If a tenant truly must not be able to affect the control plane of others, namespaces and fairness settings are not enough. Virtual clusters or separate clusters give that tenant its own API server, and the shared one is spared.

14Beyond Static Quotas: Fair Sharing, Priorities and Queues

A hard quota is simple but rigid. Here is how platforms add flexibility.

The rigidity of fixed caps

A ResourceQuota is a hard wall. If tenant A is idle and tenant B needs more, B still cannot exceed its own cap, even though the cluster is half empty. Conversely, if every tenant is given a generous cap, the sum exceeds real capacity and the first tenants to claim resources win. Neither extreme is ideal. Many platforms want guaranteed minimums, with the ability to borrow idle capacity from others.

Priorities and preemption

Priority classes let important Pods outrank others. When the cluster is full, a high-priority Pod can cause lower-priority Pods to be evicted to make room. Combined with quotas scoped to a priority class, a platform can say: “each tenant may run a small amount of high-priority work, and any amount of low-priority batch work that can be preempted.” This gives soft guarantees without wasting idle capacity.

Simple Analogy

Priorities are like an airport’s boarding order. Everyone has a ticket, but when the plane is overbooked, passengers with higher status keep their seats and others get bumped. A fair airline also limits how many top-status seats each group can claim.

Queueing systems with borrowing

For batch and machine learning platforms, a family of queueing tools sits in front of the scheduler. Tenants submit jobs to queues that have a nominal share of resources, and queues may borrow unused share from others within a group, then give it back when owners need it. The queueing layer decides when a whole job is allowed to start, and the ordinary scheduler places its Pods. This provides fairness and good utilisation that static quotas cannot.

ApproachGuaranteeFlexibilityComplexity
Hard quota per namespaceCap only, no reservationNone, fixed ceilingVery low
Quota scoped by priority classCaps per priority tierModerate, preemption helpsLow
Queue-based sharing with borrowingNominal shares, with borrowingHighMedium to high
Dedicated node poolReal reservationLow, idle space is wastedMedium
i
Start Simple

Begin with plain quotas and defaults. Add priority classes and queueing only when you can show that idle capacity is being wasted or that tenants are being treated unfairly. Each added layer is another thing to operate and explain.

15Tenancy Frameworks, Hierarchies and Virtual Clusters

Tools that package the layers together so you do not hand-build every tenant.

The problem with hand-built tenants

Each tenant needs a namespace, a quota, a limit range, access bindings, network policies, security labels and node placement rules. Creating these by hand is slow and error-prone, and tenants with more than one namespace multiply the work. Differences creep in, and some tenant ends up without a default-deny policy. Automation and tenancy frameworks reduce this risk.

Hierarchical namespaces

A hierarchy lets one namespace be the parent of others, with policies such as access rules and network rules flowing down from parent to child automatically. A team can then create sub-namespaces for its own projects and environments without involving the platform team each time, while inheriting the team’s guardrails. This is especially useful where one tenant owns many namespaces.

Tenant abstractions

Some projects add a tenant object that groups several namespaces and applies shared quotas, access rules, network rules and policies across them. Instead of one quota per namespace, the tenant has a total budget that its namespaces share. Tenant owners may create their own namespaces within limits, and the framework stamps each with the standard guardrails.

Virtual clusters

A virtual cluster gives each tenant its own API server and its own set of cluster-scoped objects, running as a workload inside the shared host cluster. The tenant sees what looks like a full cluster, where they can install their own definitions and create their own namespaces, while their Pods actually run on the shared nodes, mapped into a host namespace. This restores a lot of tenant freedom and protects the host’s control plane, at the cost of more components and some compatibility questions.

flowchart TD
  H["Shared host cluster"] --> NS1["Tenant A host namespace"]
  H --> NS2["Tenant B host namespace"]
  NS1 --> V1["Virtual control plane for tenant A"]
  NS2 --> V2["Virtual control plane for tenant B"]
  V1 --> P1["Tenant A Pods run on shared nodes"]
  V2 --> P2["Tenant B Pods run on shared nodes"]
        
FIG 5 — Virtual clusters: each tenant gets its own API server, while the Pods share the host cluster’s nodes

Automation through version control

Even without a framework, you can store tenant definitions in version control and apply them with a continuous delivery tool. A new tenant becomes a reviewed change request, producing a consistent set of objects every time.

Self-service portals

Some organisations offer a catalogue where a team requests a tenant with a chosen size, and automation creates everything. The portal enforces standards and records ownership.

!
Check What Each Tool Really Isolates

Virtual clusters isolate the API layer, but Pods may still share the host’s nodes and kernel unless you combine them with dedicated nodes or sandboxes. Frameworks automate policies, but cannot create isolation that the underlying policies do not provide. Read each tool’s documentation for its exact guarantees and for the Kubernetes versions it supports.

16A Blueprint for Provisioning a Tenant Namespace

The same ordered steps, every time, produce a tenant that is safe from its first minute.

1

Create the namespace with identity labels

Add labels for tenant name, owner, environment and cost centre. These feed policies, billing and incident response.

2

Set the security profile labels

Apply enforcement of the restricted or baseline profile, with audit and warn modes alongside, from the very start.

3

Apply the quota and limit range

Set totals for compute, storage and object counts, and defaults and maximums per container and claim.

4

Apply default-deny network policies and allowed paths

Block all by default, then allow DNS, ingress, same-namespace traffic and any approved shared services.

5

Bind access roles to the tenant’s groups

Give developers a namespace-scoped role and administrators a slightly broader one, with no cluster-wide rights.

6

Configure service accounts and tokens

Create purpose-specific accounts, strip power from the default one and disable automatic token mounting where not needed.

7

Add node placement rules when needed

Attach automatic toleration and selector rules for dedicated pools, or the runtime class for sandboxed workloads.

8

Wire up monitoring, logging and alerts

Make sure quota usage, errors and policy violations for this tenant are visible and routed to the right people.

9

Verify with an automated test

Check that a test Pod cannot exceed its quota, cannot reach another tenant and cannot run with forbidden settings.

i
Test the Isolation, Do Not Assume It

The last step is the one most often skipped. A small automated test that tries to break the rules proves that your layers work together and keeps working after upgrades and policy changes.

Offboarding is part of the blueprint

When a tenant leaves, deleting the namespace removes the objects inside it, but cluster-scoped leftovers remain: volumes with a retain policy, cluster-level bindings, node pool labels and external resources created by the tenant’s workloads. Keep a checklist for offboarding, and make sure data is exported or deleted deliberately, because namespace deletion can be slow and can hang on objects that block removal.

17Real-World Use Cases

How different kinds of organisations apply the layers in practice.

Internal platform for product teams

A company gives each product team a namespace per environment, with quotas matched to the team’s budget, default-deny network rules, the restricted security profile and access through the company’s identity groups. Trusted teams share nodes. This is the classic soft multi-tenancy setup, and it works well when teams are accountable to the same organisation.

Separating environments

Development, testing and production often share a cluster at small scale, separated by namespaces with different quotas and policies. As the stakes rise, organisations move production to its own cluster or dedicated node pools so that experiments cannot touch it.

Software service with a namespace per customer

A software provider runs one namespace per customer for the application’s own components. Here the customers do not run code themselves, so threats come from application bugs. Strong quotas, network isolation and careful handling of Secrets matter most. Customers with strict needs may get a dedicated cluster.

Platforms that run customer-supplied code

Code execution services, notebooks and build systems run untrusted code on purpose. These need the hard multi-tenancy toolkit: sandboxed runtimes, dedicated nodes, tight network egress rules, tight resource caps, and often a separate cluster per customer segment.

Shared machine learning and data clusters

Teams share expensive accelerators. Per-namespace quotas on accelerators, priority classes and queueing with borrowing let teams use idle devices while guaranteeing a baseline for each.

Regulated workloads

Where rules require data separation, organisations commonly add dedicated node pools or separate clusters for regulated tenants, together with strict audit, encryption and access logging, and treat the shared cluster as untrusted for that data.

ScenarioTrust levelTypical layers
Internal product teamsHighQuotas, access rules, default-deny, restricted profile
Dev, test and production togetherHigh, but high stakesAbove plus dedicated pools or separate production cluster
Customer namespaces for your own applicationMediumAbove plus strict Secret handling and egress control
Customer-supplied codeLowSandboxed runtimes, dedicated nodes, strong egress limits, often separate clusters
Regulated dataLow for the shared layerDedicated infrastructure, audit trails, encryption

18Performance and Scalability of Multi-Tenant Clusters

More tenants means more objects, more policies and more traffic through the same control plane.

What grows with the number of tenants

Each namespace adds objects: quotas, ranges, policies, bindings and service accounts. Each tenant adds workloads, which add Pods, Services and watch connections from controllers and monitoring. Network policies are translated by the network plugin into rules on every node, so many policies increase per-node work. Quota and policy evaluation add a small cost to each request.

Lever 1

Keep policies simple and few

Use selectors that cover many Pods, and standard templates, rather than hundreds of near-duplicate policies.

Lever 2

Cap object counts early

Object count quotas stop any tenant from creating the large numbers of objects that slow listing and bloat the database.

Lever 3

Scope controllers and webhooks

Controllers that watch only needed namespaces cost less. Webhooks scoped by label avoid slowing unrelated requests.

Lever 4

Use fairness settings for heavy tenants

Give automated tenants their own priority and flow configuration so their bursts stay contained.

Lever 5

Know when to split

When a single cluster’s size, blast radius or upgrade risk becomes uncomfortable, adding another cluster is often better than stretching one further.

The blast radius question

Whatever the performance numbers say, a single shared cluster has a single blast radius. A faulty upgrade, a misconfigured global policy or a control plane outage affects every tenant at once. Many organisations choose several medium clusters, each hosting a group of tenants, as a balance between the efficiency of sharing and the safety of separation.

!
Global Policies Are Global Risks

A single faulty admission rule or webhook can block deployments for every tenant. Roll out cluster-wide policy changes gradually, test them first in audit or warn mode, and have a fast rollback.

19Security Considerations: What Namespaces Cannot Stop

A realistic list of gaps, so you can close them or accept them knowingly.

Residual risks, even with every layer in place

Shared kernel

Unless you use dedicated nodes or sandboxes, containers from different tenants share a kernel. A serious kernel flaw can allow escape. Keep nodes patched, and place less trusted workloads on stronger boundaries.

Shared control plane and database

Every tenant’s objects live in the same database. Protect it with encryption of Secrets at rest, strict access to the database itself and careful backup handling, because a backup contains every tenant’s data.

Cluster-scoped objects

Definitions, cluster roles, webhooks and volumes are shared. Do not let tenants create them. A single tenant-created webhook could see every tenant’s requests.

Volume handling

Persistent volumes are cluster-scoped, and a tenant who can create one directly may point it at someone else’s storage. Tenants should create claims only, and storage classes should isolate tenants’ data where required.

Shared platform services

Ingress controllers, DNS, monitoring and logging are shared. Check that metrics and logs from one tenant cannot be read by another, and that the ingress layer cannot route one tenant’s hostnames to another’s services.

Information leakage through names and metadata

Namespace names, labels and events can reveal other tenants’ existence or customer names. Use neutral naming and limit who can list namespaces cluster-wide.

Protecting the guardrails themselves

All the layers rely on objects that live in or near the tenant namespace: quotas, policies, role bindings and labels. If a tenant can edit or delete them, the protection vanishes. Make sure tenant roles can neither modify nor delete these objects, and use admission rules to protect the security-relevant labels on namespaces.

!
Secrets Deserve Extra Care

Enable encryption for Secrets in the cluster database, restrict who can read them, prefer short-lived credentials from an external secret manager, and never share one Secret across tenants. A tenant able to read a Secret can use its credentials anywhere they are valid.

Audit and detection

Turn on audit logging and keep it long enough for investigations. Alert on attempts to create cluster-scoped objects from tenant identities, on changes to quotas and policies, on creation of privileged Pods that were denied, and on cross-namespace access attempts. Regular scans that compare each tenant namespace against the blueprint will reveal drift early.

20Monitoring, Logging and Chargeback

Tenants need to see their usage, and operators need to see who is close to a limit.

What to measure per tenant

Metric idea

Quota usage against limit

Used versus hard amounts for each quota item. Alert tenants and operators when usage nears the cap, before deployments start failing.

Metric idea

Requested versus actually used

Compare reserved CPU and memory with real consumption. Large gaps mean wasted reservations and are a chance to right-size and save money.

Metric idea

Throttling and out-of-memory kills

Containers that hit their CPU ceiling or are killed for memory show that limits are too tight for the workload.

Metric idea

Pending and failed Pods

Pods stuck pending or controllers failing to create Pods point to quota, capacity or policy problems.

Metric idea

Admission denials

Counts of requests refused by quotas and policies, grouped by tenant and reason, reveal confusing rules and misbehaving automation.

Metric idea

API request rates per tenant

Which tenants send the most requests and how often they are queued by fairness settings.

Chargeback and showback

Because quotas and labels tie usage to a tenant, you can report cost per tenant. Showback shows each tenant what they consume and what it costs. Chargeback actually bills them. Both depend on consistent ownership labels on every namespace and workload, which is another reason to enforce labels at admission. Shared overhead, such as the control plane and monitoring, is usually split by an agreed formula.

Where tenants look when something fails

Events in their namespace

Quota refusals, scheduling failures and policy violations appear as events. Teach tenants to read them first, and make sure events live long enough to be useful.

Dashboards scoped to the tenant

Give each tenant a dashboard of their own usage and quota, and restrict their view to their own namespaces, so self-service reduces support requests.

Policy reports

Audit-mode results show tenants which of their workloads would violate a stricter rule, giving them time to fix before enforcement.

21Troubleshooting Limit-Related Failures

The same few messages account for most support requests. Learn to decode them.

A path for “my workload is not running”

1

Check what the controller created

Is the Deployment, Job or StatefulSet showing fewer Pods than wanted? If so, look at events on its child objects and on the namespace.

2

Read the refusal message

Quota refusals name the exceeded resource and show requested, used and limited amounts. Policy refusals name the rule that blocked the object.

3

If Pods exist but are pending, check scheduling

A Pod accepted by quota can still be unschedulable because of node capacity, taints, selectors or storage constraints.

4

If Pods start and then die, check runtime limits

Memory kills and CPU throttling mean the declared limits are lower than real needs.

5

If connections fail, check network policies

A missing allow rule, especially for DNS, produces timeouts that look like application bugs.

6

If access is denied, check roles and bindings

Forbidden messages name the user, the action and the namespace, which reveals the missing permission.

SymptomLikely causeWhat to do
Create refused: exceeded quotaNamespace budget for that resource is used upFree resources, right-size requests, or ask the platform team to raise the quota
Create refused: must specify CPU or memoryQuota exists but no defaults suppliedSet sizes on containers, or add a LimitRange with defaults
Create refused: maximum exceededContainer is larger than the LimitRange maximumReduce size, split the workload, or request a higher maximum
Deployment shows fewer Pods than desired, no error on applyChild Pod creation refused by quota or policyRead events on the ReplicaSet and namespace
Pod rejected for security settingsViolates the namespace’s Pod security profileAdjust the Pod, such as non-root user and dropped capabilities
Timeouts between services after tenant onboardingDefault-deny network policy missing an allow ruleAdd allows for DNS and required service paths
Pod pending although quota has roomNo node fits, or taints and selectors exclude all nodesCheck node capacity, taints and selectors on the Pod
Namespace stuck terminatingObjects with finalizers or unavailable APIs block deletionFind the blocking objects and resolve them properly
i
Make Errors Self-Explanatory

Link a short runbook from your platform documentation for each common refusal. Tenants who can decode their own errors raise far fewer tickets, and the platform team spends its time on real problems.

22Design Patterns and Best Practices

Habits that keep shared clusters calm and fair.

Patterns that work

Namespace as a stamped template

Every tenant namespace is created from one reviewed template containing labels, quota, limit range, network policies, security labels and bindings. Differences are explicit parameters, not hand edits.

Platform-owned guardrails, tenant-owned workloads

The platform team owns quotas, policies, bindings and cluster-scoped objects. Tenants own their Deployments, Services and application configuration. The split is enforced by permissions, not by trust.

Deny by default, allow by exception

Start with default-deny networking, the restricted security profile and minimal roles. Open specific paths when a tenant shows a real need, and record the reason.

Quota plus default plus alert

Pair every quota with a LimitRange for defaults, and with an alert at a high usage threshold, so tenants are warned before a refusal stops a release.

Audit before enforce

Introduce each new policy in audit or warn mode, review the violations, help tenants fix them, and only then switch to enforcement.

Test the isolation continuously

Run automated checks that attempt forbidden actions from a tenant identity and expect refusals, as part of upgrades and policy releases.

Match isolation to risk

Use the shared pool for trusted teams, dedicated pools or sandboxes for riskier workloads, and separate clusters for the highest stakes, instead of one answer for everyone.

Do

  • Define your threat model and tenancy model before building anything
  • Create quotas and limit ranges together, for every tenant namespace
  • Apply default-deny network policies at namespace creation
  • Enforce a Pod security profile and require ownership labels
  • Keep tenants out of cluster-scoped objects and guardrail objects
  • Monitor quota usage and alert before the cap is reached

Do not

  • Treat a namespace as a security boundary on its own
  • Give tenants cluster-wide roles or the ability to edit quotas
  • Let the sum of quotas silently exceed real capacity without a plan
  • Allow privileged Pods, host mounts or host networking for tenants
  • Share Secrets or service accounts across tenants
  • Run untrusted code on shared nodes without extra isolation

23Common Mistakes and Anti-Patterns

Failures that appear again and again in shared clusters.

ANTI-PATTERN-01 Avoid
Problem

The platform creates one namespace per team and considers the job of isolation done.

Why It’s Harmful

Without quotas, access rules, network rules and security profiles, any team can consume the whole cluster, reach every other team’s services, and run dangerous Pods. The namespace is only a label.

Correct Approach

Treat the namespace as the hook for a full set of guardrails created from a template at the moment of creation.

ANTI-PATTERN-02 Avoid
Problem

A quota on CPU and memory is applied, but no LimitRange supplies defaults.

Why It’s Harmful

Every workload that omits sizes is refused with confusing messages, and teams respond by setting huge limits just to get through, wasting the budget.

Correct Approach

Pair each quota with a LimitRange that sets sensible default requests and limits and a per-container maximum.

ANTI-PATTERN-03 Avoid
Problem

Tenant administrators are given a role that lets them edit quotas, limit ranges, network policies or namespace labels.

Why It’s Harmful

The tenant can raise its own cap, remove the default-deny policy or change the labels that policies depend on, which cancels the controls that were supposed to constrain it.

Correct Approach

Reserve edit rights on guardrail objects for the platform team, and protect security labels with an admission rule.

ANTI-PATTERN-04 Avoid
Problem

Network policies are written for a tenant, but the cluster’s network plugin does not enforce them.

Why It’s Harmful

The objects exist and look reassuring, yet traffic between tenants flows freely. The false sense of security is worse than knowing the network is open.

Correct Approach

Confirm that your network plugin enforces policies, and include a cross-tenant connection test in your automated checks.

ANTI-PATTERN-05 Avoid
Problem

Quotas are set for every tenant based on wishes, and their sum is far greater than the cluster’s actual capacity.

Why It’s Harmful

When several tenants use their full budget, the cluster cannot satisfy them. Pods wait pending, and whoever happened to deploy first wins, which feels unfair and unpredictable.

Correct Approach

Plan capacity against the sum of quotas, decide the overcommit ratio on purpose, use priorities for important work, and add capacity before the ceiling is reached.

ANTI-PATTERN-06 Avoid
Problem

A service hosting customer-supplied code relies on namespaces and quotas alone on shared nodes.

Why It’s Harmful

A customer who escapes their container lands on a node shared with others and can reach their data, and quotas do nothing against a kernel-level attack.

Correct Approach

Add sandboxed runtimes, dedicated nodes, strict egress controls and, for the highest risk, separate clusters.

ANTI-PATTERN-07 Avoid
Problem

Tenants are allowed to install custom resource definitions, webhooks or cluster-wide operators directly.

Why It’s Harmful

These objects are cluster-wide. One tenant’s webhook can see or block other tenants’ requests, and conflicting definitions can break shared components.

Correct Approach

Keep cluster-scoped installations with the platform team, or offer virtual clusters to tenants who need their own definitions.

ANTI-PATTERN-08 Avoid
Problem

Namespaces are created by hand, and each ends up with a slightly different set of guardrails.

Why It’s Harmful

Some tenants have no network policy or quota, and nobody notices until an incident. Drift makes the cluster’s real security impossible to state.

Correct Approach

Create tenants from version-controlled templates, scan for drift regularly and treat any manual difference as a defect.

24Advantages, Disadvantages and Trade-offs

An honest balance sheet for namespace-based multi-tenancy.

Advantages

  • Efficient use of hardware and lower operating cost than a cluster per tenant
  • Fast, cheap onboarding of new tenants through templates
  • Familiar, built-in tools with broad community knowledge
  • Shared platform services installed and maintained once
  • Clear unit for access, quotas, billing and policy
  • Flexible: layers can be added as trust requirements grow

Disadvantages / Trade-offs

  • Namespaces alone do not isolate network, kernel or control plane
  • Many layers must be configured correctly and kept consistent
  • Shared blast radius: global mistakes affect every tenant
  • Cluster-scoped objects are shared and hard to delegate safely
  • Static quotas are rigid and can waste or oversubscribe capacity
  • Hard multi-tenancy needs extra, costly measures

Choosing between sharing and separating

SituationBest fitWhy
Many small trusted teamsShared cluster with namespaces and policiesEfficiency with adequate safety
Production versus experimentsSeparate clusters or dedicated poolsLimits blast radius of mistakes
Tenants needing their own definitions and API objectsVirtual clustersFreedom without touching the host’s control plane
Customer-supplied codeSandboxes, dedicated nodes, often separate clustersWithstands deliberate attack
Strict regulatory separationSeparate clusters or accountsClear, auditable boundary
Shared expensive acceleratorsQuotas, priorities and queueing with borrowingFairness with high utilisation
“A namespace is where you hang your protections. It is never the protection itself.”

25Frequently Asked Questions

Questions that beginners and experienced engineers keep asking.

Q1Is a namespace a security boundary?

Not by itself. It scopes names and is a convenient place to attach access rules, quotas and policies, but with no policies attached, tenants can reach each other’s services and use the whole cluster. Security comes from the layers you add.

Q2What is the difference between a ResourceQuota and a LimitRange?

A quota caps the total amount of resources and objects in a namespace. A LimitRange sets defaults and minimum and maximum sizes for each individual container, Pod or claim. You normally need both: one to bound the whole, the other to shape the parts.

Q3Why does my workload get refused for not setting CPU or memory?

Because the namespace has a quota on those resources, and the system cannot add up a container with no declared size. Either set sizes on your containers, or ask for a LimitRange that supplies defaults.

Q4If I lower a quota, will running Pods be killed?

No. Quotas are checked when objects are created or changed. Existing Pods keep running. Only new creations that would exceed the lowered cap are refused.

Q5Why did my Deployment apply successfully but show no Pods?

The Deployment object itself was accepted, but the Pods created on its behalf were refused by a quota or policy. The refusal appears as events on the ReplicaSet or namespace, not as an error on the apply.

Q6Can tenants in different namespaces talk to each other by default?

Yes. Kubernetes networking is open by default. Use network policies, with a default-deny starting point, and a network plugin that enforces them, to block cross-tenant traffic.

Q7Do quotas guarantee that a tenant gets the resources?

No. A quota is a ceiling, not a reservation. If the cluster is full, a tenant within its quota can still have Pods stay pending. Guarantees need capacity planning, priorities, dedicated node pools or queueing systems with nominal shares.

Q8How do I stop one tenant from overloading the API server?

Use the API priority and fairness settings to give heavy tenants their own flows, cap object counts with quotas, scope webhooks and controllers narrowly, and teach tenants efficient access patterns. For strict protection, give the tenant a virtual or separate cluster.

Q9Is it safe to run customer-supplied code in a shared cluster with namespaces?

Not with namespaces alone. Add sandboxed runtimes, dedicated nodes, strict egress rules, strong resource caps and tight Pod security profiles, and consider a separate cluster for the highest-risk customers.

Q10What are virtual clusters and when should I use them?

A virtual cluster gives each tenant its own API server and cluster-scoped objects, running inside a shared host cluster. Use them when tenants need freedom to install definitions or create namespaces, or when you want to shield the host’s control plane. They do not by themselves isolate the nodes and kernel.

Q11How many namespaces can a cluster hold?

There is no single number, since it depends on how many objects each namespace holds, the size of the control plane and the load. Large clusters run thousands of namespaces, but practical limits come from total object counts, watchers and request rates, so measure your own setup.

Q12What should every new tenant namespace contain?

Identity and cost labels, Pod security profile labels, a quota and a LimitRange, default-deny network policies with the needed allow rules, namespace-scoped access bindings for the tenant’s groups, locked-down service accounts, and monitoring wiring. Create them from a template and test the result.

26Summary and Key Takeaways

Multi-tenancy lets many teams or customers share one Kubernetes cluster to save cost and effort, but a namespace alone is only a naming scope. Isolation appears when you attach layers to it. Quotas cap the totals of CPU, memory, storage and object counts, and LimitRanges set defaults and per-object bounds, with quota checks happening at admission when objects are created. Access rules confine people and programs to their own namespace, network policies close the open network, Pod security profiles and admission policies block dangerous settings, and dedicated nodes or sandboxed runtimes separate tenants at the machine level. Fairness settings and object count caps protect the shared control plane. Frameworks, hierarchies, queues and virtual clusters package or extend these layers for larger or riskier setups.

Return to the office building from the start. The floor number on the door is only a label. The security comes from the electricity cap, the locked doors, the badge rules, the building code and the guards at reception, all set up the same way for every new tenant and checked regularly. Decide honestly how much you trust your tenants, build the layers to match, create each tenant from a tested template, and a shared cluster becomes both economical and safe.

Key Takeaways

  • A namespace is a hook, not a wall — it scopes names and carries policies; isolation exists only where quotas, access rules, network rules, security profiles and node placement are attached.
  • Know your threat model — namespaces plus policies suit trusted teams (soft multi-tenancy), while untrusted code needs sandboxes, dedicated nodes, virtual clusters or separate clusters.
  • Pair ResourceQuota with LimitRange — the quota caps the namespace total at admission time, the LimitRange fills in defaults and bounds each object, and neither evicts running Pods.
  • Close the open network — start with default-deny network policies on an enforcing network plugin, and allow DNS, ingress and required paths explicitly.
  • Keep guardrails out of tenant hands — tenants must not edit quotas, policies, bindings, security labels or cluster-scoped objects such as definitions and webhooks.
  • Protect the shared control plane and the shared kernel — use API fairness and object count caps for the former, and dedicated pools or sandboxed runtimes for the latter.
  • Automate, observe and test — create every tenant from a version-controlled template, alert on quota usage and violations, plan capacity against the sum of quotas, and prove the isolation with automated tests.