Multi-tenancy: namespaces, ResourceQuota, LimitRange, PriorityClass, noisy neighbours, and when to split clusters

ResourceQuota caps a namespace's requests at admission; LimitRange sets per-pod defaults and bounds. Neither stops a noisy neighbour on a shared node — that is node pools and priority.

Read the briefing
About 3 min to read 7 drills

What to remember

  1. Quota is admission-time and counts requests. It never limits actual usage. A quota rejection appears on the ReplicaSet, not the Deployment.
  2. A compute quota forces every pod to declare requests. So LimitRange defaults are its mandatory companion.
  3. Default CPU limits from a LimitRange throttle everyone. Default requests always, memory limits usually, CPU limits almost never.
  4. Noisy neighbours are placement, not quota. Honest requests, PriorityClasses, then tainted node pools.
  5. Split clusters for blast radius or compliance, not for teams. Every extra cluster multiplies upgrades, add-ons and on-call.

The big picture

A shared cluster is a negotiation between teams over CPU, memory, storage, and the control plane itself. Namespaces are the boundary, ResourceQuotas cap what a namespace may consume in aggregate, LimitRanges set defaults and bounds per pod, PriorityClasses decide who yields under pressure, and the decision of when to split clusters is about blast radius and the control plane, not about CPU. Interviewers use this topic to see whether you can keep forty teams from hurting each other without turning the platform team into a ticket queue.

The mental model

Three concentric fences. LimitRange fences a single pod: defaults for containers that forgot requests, and min/max bounds. ResourceQuota fences a namespace: the sum of requests, limits, object counts, and storage. PriorityClass plus preemption decides what happens when the cluster itself is the fence. Splitting clusters is the last fence: for blast radius, compliance, or control-plane scale, never because a quota could not express a rule.

In depth

ResourceQuota: the namespace fence

A ResourceQuota lives in a namespace and caps aggregate usage: requests.cpu, requests.memory, limits.cpu, limits.memory, pods, services.loadbalancers, persistentvolumeclaims, requests.storage, and per-class storage (<class>.storageclass.storage.k8s.io/requests.storage). Once a compute quota exists in a namespace, every pod must specify the quota'd resource or it is rejected, which is why LimitRange defaults are the companion. Quota is enforced at admission (create/update), not at runtime: it counts what pods request, not what they use. kubectl describe quota -n <ns> shows used vs hard; a Deployment whose pods are rejected by quota shows the failure in the ReplicaSet's events, not the Deployment's, which fools people. Scope selectors can apply quotas to a PriorityClass (for example, cap how much high priority a team may request) or to BestEffort pods.

LimitRange: the pod fence, and the defaults problem

A LimitRange sets per-container and per-pod default (limits), defaultRequest, min, max, and a maxLimitRequestRatio. Its most important job is filling in requests for containers that omit them, so quotas can be enforced and scheduling stays honest. Its most common misuse is a default CPU limit that silently throttles every workload in the namespace (see the QoS topic): defaults should be requests-first, with memory limits always present and CPU limits deliberate. LimitRange applies at admission; existing pods are not retroactively changed.

Priority, noisy neighbours, and when to split clusters

Noisy neighbours in Kubernetes come in three flavours: compute (a team's batch jobs starve latency-critical pods on shared nodes: fix with requests, quotas, PriorityClasses with preemption, and node pools with taints for the truly sensitive), network/disk (pods saturating a node's NIC or disk: fix with node pools, bandwidth annotations where the CNI supports them, and separate storage classes), and control plane (a team's operator hammering the API server with list calls, or millions of ConfigMaps bloating etcd: fix with API Priority and Fairness, object-count quotas, and admission policies).

Split clusters when: blast radius of a control-plane failure must be bounded (production vs everything else), compliance demands isolation that namespaces cannot certify, the control plane is at scale limits (etcd size, node count, object churn), or teams need different Kubernetes versions or CNIs. Do not split because someone wants their own cluster-admin; that is a tenancy design problem. Every extra cluster multiplies upgrades, add-ons, observability, and cost; the platform answer is usually one production cluster per region with strong tenancy plus a separate non-production cluster.

Myths and facts

Myth: ResourceQuota limits how much CPU pods actually use.

Fact: It caps the sum of requests (and limits) at admission time; actual usage is governed by limits and cgroups.

Myth: A pod rejected by quota shows the error on the Deployment.

Fact: The ReplicaSet tries to create pods and records the FailedCreate event; the Deployment just shows fewer replicas.

Myth: LimitRange defaults apply to pods that already exist.

Fact: They apply at admission to new pods; existing pods keep what they had.

Myth: Every team should get its own cluster for isolation.

Fact: Namespaces plus quotas, RBAC, NetworkPolicy, and PSA give most teams the isolation they need; extra clusters are expensive and justified by blast radius, compliance, or scale.

Myth: Quota on 'pods' stops a team from consuming the cluster.

Fact: Pod count says nothing about size; quota requests.cpu and requests.memory, and storage.

How pros do it

  • Every tenant namespace ships with a ResourceQuota (requests.cpu, requests.memory, limits.memory, requests.storage, object counts) and a LimitRange with request defaults and a memory-limit default.
  • Size quotas from measured usage plus headroom and review them quarterly; a quota nobody hits is fine, a quota everyone hits is a ticket generator.
  • Reserve PriorityClasses: system > platform > latency-critical > default > batch, and cap high-priority requests per team with a scoped quota.
  • Use node pools with taints for workloads that must not share nodes (latency-critical, GPUs, compliance).
  • Decide cluster splits on blast radius and control-plane scale; keep the count small and identical (same add-ons, same versions, GitOps-managed).

Questions people ask

My Deployment says 3 desired, 1 available, no events. Where is the error?

One level down, on the ReplicaSet: kubectl describe rs shows FailedCreate with the quota message (for example exceeded quota: requests.memory). Quota, LimitRange and Pod Security rejections all surface there, never on the Deployment — say that rule and you have answered the whole family of questions.

Why did my pod get rejected with 'must specify requests.cpu' after we added a quota?

A compute quota requires every pod to declare that resource; add requests or a LimitRange with defaults.

How many clusters should a company with 40 teams run?

Usually few: one production cluster per region with strong tenancy, one non-production, maybe one for regulated workloads. Count clusters by blast radius and compliance, not by teams.

How big should a team's quota be?

Measured p95 of their requests plus 30–50% headroom, revisited when they hit 80% for a week; quotas are a conversation starter, not a punishment.

Can two namespaces share a quota?

Not natively; hierarchical namespaces or a policy engine can approximate it, or give the team one namespace with a larger quota.

Further reading

Drills · 7

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Pick the strongest answer

'When does a workload deserve its own cluster instead of a namespace?' Which of these is the strongest reason?

  1. The team wants cluster-admin to install operators. A tenancy and RBAC design problem, not a reason to multiply clusters.
  2. The team prefers a different ingress controller. Multiple ingress classes can coexist; preferences are not isolation requirements.
  3. A regulatory boundary requires that no other tenant share the control plane or nodes, and a control-plane incident must not affect other environments. Blast radius and compliance are properties a namespace cannot provide.
  4. The workload needs 200 CPU cores. Quotas and node pools handle size within a cluster.
In short

A separate cluster is justified by compliance and blast radius, things a namespace cannot provide.

Why

Every cluster multiplies upgrades, add-ons, monitoring, and on-call surface. Split for blast radius, compliance, control-plane scale, or genuinely incompatible platform requirements (Kubernetes version, CNI). Everything else is tenancy design inside a cluster.

The common mistake

Treating 'the team wants cluster-admin' or 'it needs 200 cores' as a reason. Those are RBAC and quota problems inside a cluster; only isolation a namespace cannot provide justifies a new control plane.

Read the docs

2 Scenario: what do you do next?

A shared production cluster runs latency-critical RPC gateways (team A) and a data team's backfill jobs (team B). Every evening the backfill starts, gateway p99 doubles, and twice this month gateway pods were evicted from nodes under memory pressure. Both teams have quotas.

Step 1. What do you look at first?

  1. Halve team B's quota. Quota caps requests at admission; the evictions come from usage over requests on shared nodes.
  2. Move team A to a new cluster. Possibly later; first exhaust the in-cluster tenancy tools, which are cheaper and faster.
  3. Node-level evidence: which pods share nodes with the gateways, their QoS classes and requests vs usage, and whether the evictions correlate with backfill pods over their requests (kubectl describe node, eviction events). Noisy neighbour is a placement and QoS problem; the node view shows who is over their requests and who is Burstable.
  4. Increase the gateways' replicas. More gateway pods on the same noisy nodes get evicted too.

Step 2. Backfill pods request 1Gi but use 6Gi (Burstable); gateways are Burstable too with requests below usage. Mitigation for tonight?

  1. Disable node-pressure eviction on the nodes. Then the kernel OOM killer decides, which is worse.
  2. Make the gateways Guaranteed (requests = limits from observed p95) with a higher PriorityClass, and give backfill honest memory requests or a memory limit so it is the one evicted; if hardware allows, taint a node pool for latency-critical pods. The kubelet evicts pods whose usage exceeds their requests first, ordered by priority and then by how far over they are; honest requests keep the gateways under their requests (Guaranteed makes that structural) and a higher priority breaks ties, so the backfill, at six times its request, is the one that goes.
  3. Set memory limits on the gateways so they are protected. Limits on the victim do not stop the neighbour from causing node pressure; and a low limit OOMKills the gateway.
  4. Pause the backfill indefinitely. The data team has a deadline too; the platform should let both coexist.

Step 3. Stable for a week. Systemic policy?

  1. One cluster per team. Multiplies operations without fixing dishonest requests, which would recur inside each cluster.
  2. Ban Burstable pods. Guaranteed everywhere wastes capacity; the fix is honest requests and priority, not a QoS ban.
  3. Tenancy baseline: quotas on requests and limits per namespace, LimitRange defaults, a PriorityClass ladder with scoped quotas, taints for latency-critical node pools, VPA-in-recommendation for right-sizing, and alerts on evictions and throttling. Split clusters only if the gateway SLO needs control-plane isolation. Mechanisms that keep the two workloads honest and separated where it matters, with the cluster split kept as a deliberate escalation.
In short

Look at the shared nodes first, then give the gateways honest requests, Guaranteed QoS and higher priority so the backfill is evicted instead.

Why

Noisy-neighbour incidents are almost always dishonest requests meeting shared nodes. The tools, in order of cost: honest requests and QoS, PriorityClasses, quotas, tainted node pools, and only then cluster splits. Interviewers want the node-level diagnosis and the ordered toolbox.

The common mistake

Reaching for the quota or for more gateway replicas. Quota caps what a namespace may request at admission and says nothing about a pod using six times its request on a shared node; more replicas on the same nodes get evicted the same way.

Read the docs

3 Pick the strongest answer

'We added a ResourceQuota and the Deployment stopped creating pods.' The quota sets requests.cpu: "20" on namespace team-a; the Deployment's containers declare no resources. What is the cause and the standard fix?

  1. The Deployment must be recreated after a quota is added. The controller keeps trying; the pod spec is what is rejected.
  2. Quotas only work with Guaranteed pods. Quotas count requests and limits of any QoS class.
  3. With a compute quota present, every pod must declare requests.cpu or admission rejects it; add a LimitRange with defaultRequest so unspecified containers get one. Quota needs a number to count; LimitRange defaults supply it.
  4. The quota is exhausted; raise it. Nothing has been admitted yet; the rejection is about missing requests, and describe quota would show used 0.
In short

A compute quota makes every pod declare requests.cpu; add a LimitRange with defaultRequest so pods without requests get one.

Why

Quota and LimitRange are designed as a pair: quota enforces the namespace ceiling and requires declared requests; LimitRange fills defaults so teams do not have to annotate every container. The rejection appears on the ReplicaSet as a FailedCreate event.

Read the docs

4 Read the output

Why is api stuck at 4/6, and what are the two legitimate fixes?

$ kubectl -n team-a describe quota compute
Name:            compute
Resource         Used   Hard
--------         ----   ----
limits.memory    58Gi   64Gi
pods             41     100
requests.cpu     19500m 20
requests.memory  38Gi   64Gi

$ kubectl -n team-a get deploy api
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
api    4/6     6            4           2h

$ kubectl -n team-a describe rs api-7c9d5f6b8 | tail -2
  Warning  FailedCreate  30s (x14 over 12m)  replicaset-controller  Error creating: pods "api-7c9d5f6b8-x9k2l" is forbidden: exceeded quota: compute, requested: requests.cpu=1, used: requests.cpu=19500m, limited: requests.cpu=20
  1. The Deployment needs kubectl rollout restart. The ReplicaSet is already retrying; the quota decision would be identical.
  2. The node pool is full; add nodes. This is admission-time quota, not scheduling; the pods were never created.
  3. Each api pod requests 1 CPU; even one more would exceed 20 cores of requests. Either reduce requests across the namespace (right-size) or raise the quota after the team justifies the need. The event is exact: used 19.5 + requested 1 > hard 20 for the fifth pod; quota did its job.
  4. limits.memory is nearly exhausted, so pods are OOMKilled. The rejection names requests.cpu; and OOMKilled pods would exist and restart.
In short

The namespace has hit its requests.cpu quota; either lower requests or raise the quota.

Why

Quota rejections live in the ReplicaSet events and quote the arithmetic. The healthy response is a conversation: are the requests honest (VPA recommendations), and if so, is the quota sized to the team's real need?

Read the docs

5 Find what's broken

team-b's latency-sensitive API shows CPU throttling stalls, and last week the team accidentally consumed most of the cluster's memory. Which two lines are responsible?

apiVersion: v1
kind: LimitRange
metadata:
  name: defaults
  namespace: team-b
spec:
  limits:
    - type: Container
      default:
        cpu: 200m
        memory: 512Mi
      defaultRequest:
        cpu: 100m
        memory: 256Mi
      max:
        cpu: "4"
        memory: 8Gi
---
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute
  namespace: team-b
spec:
  hard:
    pods: "200"
    services.loadbalancers: "2"
In short

Line 10 sets a default CPU limit that throttles every container, and line 26 shows a quota that never caps CPU or memory requests.

What's broken
  • Line 10: A default CPU limit of 200m is applied to every container that omits limits, so the API is throttled by CFS quota regardless of node capacity.
  • Line 26: The quota caps pod count and load balancers but not requests.cpu, requests.memory, or limits.memory, so 200 pods can request the whole cluster.
Why

Two opposite failure modes from one namespace: a LimitRange that is too strict on CPU limits (throttling the innocent) and a quota that is too loose on compute (letting the namespace eat the cluster). The request defaults (line 13) and max bounds (line 16) are fine; a load-balancer cap (line 27) is a good idea.

Read the docs

6 Design round

Design multi-tenancy for a company with 40 engineering teams, 6 of which run latency-critical services and 2 of which handle regulated data. Cover cluster topology, the per-namespace baseline, how noisy neighbours are prevented, and how you would know the design works.

  • Platform team of four engineers.
  • Regulated workloads must be provably isolated from other tenants.
In short

A strong answer keeps a few clusters split by blast radius, gives every namespace a templated quota, LimitRange, RBAC and policies, and protects the control plane.

A strong answer covers
  • Cluster topology: few clusters, chosen by blast radius/compliance (prod, non-prod, regulated), identical and GitOps-managed.
  • Per-namespace baseline delivered by template: ResourceQuota on requests/limits/storage/objects, LimitRange defaults, RBAC, NetworkPolicy default-deny, PSA level.
  • PriorityClass ladder with scoped quotas; tainted node pools for latency-critical tenants.
  • Control-plane protection: API Priority and Fairness, object-count quotas, admission policies.
  • Verification: eviction and throttling alerts, quota utilization dashboards, a game day where one tenant misbehaves.
  • Tradeoffs stated: cluster count vs ops load; strictness vs team velocity.
What a strong answer does
  • design quality: Small cluster set by blast radius, templated baseline, priority ladder, node pools, APF and object quotas, verification plan.
  • tradeoffs: Two or more with decisions, e.g. strict defaults vs velocity handled by self-service quota requests.
  • communication: Restates constraints, walks a new team's onboarding, ends with how a misbehaving tenant is contained.
Why

Staff-level tenancy answers keep the cluster count small and justified, deliver the baseline as a template rather than a checklist, and include the control plane as a shared resource to protect.

Read the docs

7 Quick recall

Every pod in a namespace shows CPU throttling, yet none of the manifests sets a CPU limit and the team swears nobody added one. Which object in the namespace is injecting it?

In short

A LimitRange in the namespace injects a default CPU limit into every container that omits one.

Accepted

LimitRange · limitrange · limit range

Why

A LimitRange's default (limit) is applied at admission to every container that omits limits, so a namespace-wide CPU limit appears in pods whose manifests never set one. kubectl get limitrange -n <ns> -o yaml shows the defaults and kubectl get pod -o yaml shows the injected value; ResourceQuota, by contrast, only caps the namespace aggregate.

Next lesson Pod networking, CNI, MTU, and NetworkPolicy semantics
Drill · Multi-tenancy
0:00

Loading…