Lesson 19 of 19 · 18m
Namespaces Aren't Isolation: Quota, LimitRange, and PriorityClass
A namespace is a naming prefix and an RBAC scope, not a boundary — tenancy is what you bolt on with ResourceQuota, LimitRange, NetworkPolicy, and admission labels.
Everything about a namespace is a label. Pods in payments and pods in blog schedule onto the same nodes, share the same kernels, and resolve payments-api.payments.svc.cluster.local from either side — DNS ignores the boundary, there is no default NetworkPolicy, and RBAC only governs the API. A namespace scopes names and permissions. Nothing else. The Kubernetes multi-tenancy working group has said the quiet part for years: namespaces are "soft multi-tenancy" — fine for teams you trust, never a wall against an adversary. Multi-tenancy is a pile of other objects pointed at the namespace, and this lesson is the pile.
ResourceQuota: the budget
ResourceQuota caps what a namespace may request:
apiVersion: v1
kind: ResourceQuota
metadata:
name: payments
spec:
hard:
requests.cpu: "20"
requests.memory: 40Gi
limits.cpu: "40"
limits.memory: 80Gi
pods: "50"It counts declarations, not usage — a namespace can sit 90% idle and still refuse new pods. The trap: once quota names limits.cpu or requests.cpu, every pod in that namespace must declare that field or admission rejects it with Forbidden: failed quota. Roll quota onto a namespace that never required requests and every Deployment breaks at the next pod creation — including workloads that were running fine minutes earlier.
Quota counts more than compute: pods, count/deployments.apps, requests.storage, services.loadbalancers, services.nodeports — the last two stop a tenant from spending cloud money by creating Services. scopes narrows what quota applies to: BestEffort / NotBestEffort for pods with and without requests, Terminating / NotTerminating for Jobs and CronJobs versus long-running pods, or scopeSelector to bind quota to specific PriorityClasses — that is how you cap cheap classes without touching critical ones.
LimitRange: the default injector
LimitRange is what makes quota survivable. It mutates pods at admission — default supplies limits, defaultRequest supplies requests to pods that omitted them — and enforces min, max, and maxLimitRequestRatio. That last one matters: a pod declaring a 64Gi limit on a 1Gi request gets rejected; that asymmetry is where eviction storms breed, since requests drive scheduling and limits drive the kernel's kill list.
Set the defaults honestly. Injected defaultRequest values feed the scheduler and quota math — a default of 500m for an app that uses 50m starves the namespace's pod budget on paper while the nodes idle.
PriorityClass: who loses a fight
PriorityClass.value ranks pods cluster-wide — higher wins, and system classes like system-cluster-critical and system-node-critical sit above 2,000,000,000 so tenant workloads can never outrank cluster plumbing. When the scheduler can't fit a pod, it preempts: evicting lower-value pods on a node to make room. preemptionPolicy: Never disables it. Preemption respects PodDisruptionBudgets and gives victims graceful termination — but a quota'd tenant with a CronJob burst can still preempt a smaller tenant's pods out of shared nodes.
The rest of the boundary
- NetworkPolicy per namespace — ingress and egress default-deny, per the NetPol lesson — is the only thing stopping
paymentspods from reachingblogpods. - Pod Security labels (
pod-security.kubernetes.io/enforce=restricted) apply per namespace. - Nodes respect none of this. For hard isolation between tenants you don't fully trust, the honest tools are dedicated node pools (taints + nodeAffinity), virtual clusters via
loft-sh/vcluster, or separate clusters entirely. Namespaces carry soft multi-tenancy and nothing more.
What to actually do
New-tenant recipe, in order: namespace → restricted Pod Security labels → default-deny NetworkPolicy → ResourceQuota → LimitRange with honest defaultRequest/default → RBAC scoped to it. Then kubectl describe ns to read quota consumption — and kubectl describe resourcequota <name> -n <ns> shows exactly which hard limit is rejecting pods, with used alongside it. Quota burn is a declaration problem, not a load problem.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
What is Platform as a Service? The Sweet Spot Between "Too Easy" and "Too Much Work"
Platform as a Service sits between raw servers and fully managed software. You push code, the platform runs it. No Nginx config, no OS patches, no 3 AM server alerts. Here is what PaaS actually gives you, what it costs you in control, and how to decide if it is the right layer for your application.
The World now is Serverless and Container based
A new report from Datadog reveals that serverless computing could be entering the mainstream. This has already been the case in my world for the past few years. Results show that more than half of all organizations are using serverless on one of the three major public cloud providers: Amazon,
PostgreSQL 19 Is Out. REPACK Kept My Writes Running. The Docker Upgrade Will Stop Your App.
PostgreSQL 19 shipped on November 19 with REPACK (CONCURRENTLY), which removes table bloat without blocking writes. I measured it against VACUUM FULL, ran the upgrade from 18, and checked what breaks for self-hosters: Docker tags that refuse to start, a config setting that stops the server, and...
Self-Hosting Prometheus and Grafana: Infrastructure Monitoring That Actually Works
Build a production-grade monitoring stack with Prometheus and Grafana from scratch. Covers architecture, Docker Compose deployment, Node Exporter, alerting with Alertmanager, PromQL from basics to advanced, pre-built dashboards, and everything SudoSecurity uses to monitor its own infrastructure.