Skip to main content
Security & multi-tenancyLesson 3 of 13

Namespaces and Resource Quotas

When several teams share one cluster, Kubernetes namespaces (partitions within a cluster) and resource quotas (per-namespace resource caps) do the work. Follow along as you create partitions, set caps, and see a pod over the cap get rejected.

team-a CPU requests total—
team-a capNone
New pod result—
NS · team-aNS · team-bUserDeploy · kubectlAPI serverEntry · quota checkRBACRole·RoleBindingResourceQuotaNamespace capExisting podsteam-aNew podRequests CPU 2Existing podsteam-bCreate NS
RequestResponse / reportAppears in a later step

What you will learn

  • A namespace is a boundary for names and permissions
  • Why partitions alone do not divide resources
  • Quotas are checked when a pod is created
  • Why pods without requests get rejected
  • Permissions (RBAC) are also scoped by namespace

Try it yourself​

kubectl get namespaces
kubectl describe quota -n team-a # Hard (cap) and Used (usage)
kubectl get limitrange -n team-a # Default requests and limits
kubectl get events -n team-a | grep -i quota
kubectl auth can-i create resourcequotas -n team-a

Check yourself

  1. team-a and team-b are in separate namespaces with no quota. team-a scales up many Pods, and team-b's new Pods stay Pending. Why?
  2. team-a's quota caps CPU requests at 4 cores and 3 are in use. A Deployment scales up a Pod that requests 2 cores, but the Pod count does not go up. Where do you see the reason?
  3. In a namespace whose quota covers CPU and memory, a Pod without requests is rejected. What reduces this problem?

Further reading: Namespaces · Resource quotas · Limit ranges · Using RBAC authorization