πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Configuration intermediate ⏱ 15 minutes K8s 1.28+

Kubernetes LimitRange and ResourceQuota

Configure LimitRange and ResourceQuota in Kubernetes namespaces. Set default resource requests, enforce limits, and prevent resource exhaustion across teams.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: configuration

The Problem

This is a fundamental Kubernetes topic that engineers search for frequently. A comprehensive reference with production-ready examples saves hours of trial and error.

The Solution

LimitRange β€” Per-Pod Defaults and Limits

apiVersion: v1
kind: LimitRange
metadata:
  name: default-limits
  namespace: production
spec:
  limits:
    - type: Container
      default:               # Applied if no limits set
        cpu: 500m
        memory: 256Mi
      defaultRequest:        # Applied if no requests set
        cpu: 100m
        memory: 128Mi
      max:                   # Maximum allowed
        cpu: "4"
        memory: 8Gi
      min:                   # Minimum required
        cpu: 50m
        memory: 64Mi
    - type: Pod
      max:
        cpu: "8"
        memory: 16Gi
    - type: PersistentVolumeClaim
      max:
        storage: 100Gi
      min:
        storage: 1Gi

ResourceQuota β€” Namespace-Wide Totals

apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-quota
  namespace: production
spec:
  hard:
    requests.cpu: "20"
    requests.memory: 40Gi
    limits.cpu: "40"
    limits.memory: 80Gi
    pods: "100"
    services: "20"
    services.loadbalancers: "2"
    persistentvolumeclaims: "30"
    requests.storage: 500Gi
    count/deployments.apps: "20"
    count/secrets: "50"
# Check quota usage
kubectl describe resourcequota compute-quota -n production
# Used: requests.cpu=8, requests.memory=16Gi
# Hard: requests.cpu=20, requests.memory=40Gi
ResourceLimitRangeResourceQuota
ScopePer container/podEntire namespace
PurposeDefaults + min/max per podTotal namespace budget
EffectReject oversized podsReject when quota full
graph TD
    A[Pod submitted] --> B{LimitRange check}
    B -->|No resources set| C[Apply defaults from LimitRange]
    B -->|Exceeds max| D[Rejected]
    C --> E{ResourceQuota check}
    E -->|Namespace has room| F[Pod created]
    E -->|Quota exceeded| G[Rejected: exceeded quota]

Frequently Asked Questions

LimitRange vs ResourceQuota?

LimitRange sets per-pod defaults and boundaries (every pod gets at least X, no pod gets more than Y). ResourceQuota caps the total namespace consumption (all pods together can’t exceed Z). Use both together.

Best Practices

  • Start with the simplest configuration that meets your needs
  • Test changes in staging before production
  • Use kubectl describe and events for troubleshooting
  • Document your decisions for the team

Key Takeaways

  • This is essential Kubernetes knowledge for production operations
  • Follow the principle of least privilege and minimal configuration
  • Monitor and iterate based on real-world behavior
  • Automation reduces human error and improves consistency
#limitrange #resourcequota #resource-management #quotas #kubernetes
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens