Skip to main content

Command Palette

Search for a command to run...

Resource Quota: The Invisible Hand That Says ''Nope''

Part-8

Updated
4 min read

What is a Quota?

A quota simply means a fixed limit or allocated share of something.

It is a predefined amount of a resource that can be used within a specific period or category.

In simple words:

Quota = A controlled limit set for fair usage and better planning.


Real-Life Examples of Quota

Daily Mobile Data Quota

When your telecom provider says,
“Your daily data quota is over,”

It means you were allowed, for example, 2GB per day, and you’ve used it completely.

Why do they do this?

  • To prevent unlimited usage

  • To manage network traffic

  • To ensure fair speed for all users

Government Budget Quota

When a government announces some budget

That is also a quota.

For example:

  • 30% for health

  • 20% for infrastructure

  • 15% for education

Resource quota in k8s

In a Kubernetes cluster, there can be multiple namespaces, and each namespace is allocated its own specific set of resources. For example, the dev namespace might be assigned 2 CPUs, the test namespace 3 CPUs, and the prod namespace 5 CPUs. These allocations are defined through resource quotas to ensure proper distribution and control. Once a quota is assigned to a particular namespace, those resources are reserved for that namespace alone and cannot be used by any other namespace. This separation helps maintain stability, prevents resource conflicts, and ensures that critical environments like production are not affected by overconsumption in development or testing.

There are two types of restrictions in Resource Quota:

Requests

  • Requests mean the minimum amount of CPU or memory a pod is guaranteed.

  • Kubernetes uses this value while scheduling the pod.

  • It ensures the pod gets the required resources to run properly..

Limits

  • Limits mean the maximum amount of CPU or memory a pod can use.

  • The pod cannot exceed this value.

  • It prevents one pod from consuming too many resources.

We apply Resource Quota at the namespace level to control the total resources that namespace can use.

Inside that namespace, we define requests and limits in the workload manifest files like Deployment, StatefulSet, DaemonSet, or Job — wherever Pods are created.

Manifest File for ResourceQuota

---
apiVersion: v1
kind: ResourceQuota
metadata:
  name: dev-quota
  namespace: dev
spec:
  hard:
    requests.cpu: "2"        # Total CPU guaranteed for this namespace
    requests.memory: "4Gi"   # Total memory guaranteed
    limits.cpu: "4"          # Maximum CPU allowed
    limits.memory: "8Gi"     # Maximum memory allowed
    pods: "5"                # Maximum number of pods allowed

Manifest File for Pod

---
apiVersion: v1
kind: Pod
metadata:
  name: dev-pod
  namespace: dev
spec:
  containers:
  - name: dev-container
    image: nginx
    resources:
      requests:
        cpu: "500m"      # Minimum CPU guaranteed (0.5 CPU)
        memory: "256Mi"  # Minimum memory guaranteed
      limits:
        cpu: "1"         # Maximum CPU allowed
        memory: "512Mi"  # Maximum memory allowed

Manifest File for Deployment

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dev-deployment
  namespace: dev
spec:
  replicas: 2
  selector:
    matchLabels:
      app: dev-app
  template:
    metadata:
      labels:
        app: dev-app
    spec:
      containers:
      - name: dev-container
        image: nginx
        resources:
          requests:
            cpu: "500m"      # Minimum CPU guaranteed
            memory: "256Mi"  # Minimum memory guaranteed
          limits:
            cpu: "1"         # Maximum CPU allowed
            memory: "512Mi"  # Maximum memory allowed

Namespace → ResourceQuota → Pods → Requests & Limits

Conclusion

In Kubernetes, Resource Quotas and pod-level requests and limits work together to ensure fair and efficient use of resources. Quotas at the namespace level prevent any team or environment from consuming more than their share, while requests and limits inside Pods control the minimum guaranteed and maximum allowed resources for each container. By understanding and applying these concepts, you can keep your cluster stable, avoid resource conflicts, and plan your workloads effectively—just like managing data plans or budgets in daily life.

If you found this guide useful, please like ❤️, comment, and share your thoughts or questions. Stay tuned for the next part, where we'll explore advanced Docker concepts and practices.

Thank you,
Yours, Rama Grandhi