# Understanding Kubernetes: Part 22 Kubernetes Resource Requests & Limits

<figure><img src="https://cdn-images-1.medium.com/max/800/1*z9ZGxyjBGzobNvUR6FiLdA.png" alt=""><figcaption></figcaption></figure>

📢 If you’ve been following our **Kubernetes series 2025**, welcome back! For new readers, check out [**Part 21:** CNI](https://medium.com/@techwithpatil/understanding-kubernetes-part-21-cni-c7481aa89168)

#### What are Resource Requests & Limits in Kubernetes?

In Kubernetes, **resource requests and limits** define how much CPU and memory a container can use. This ensures fair resource allocation among workloads and prevents any single pod from consuming excessive resources, which could impact other applications running in the cluster.

* **Requests**: The minimum amount of CPU/memory guaranteed to a container. The scheduler uses this value to place the pod on a suitable node.
* **Limits**: The maximum amount of CPU/memory a container can use. If a container exceeds this, Kubernetes restricts it (for CPU) or terminates it (for memory).

For example:

If you have a microservice that processes user requests, you can set **CPU and memory requests** to ensure it has enough resources to function and **limits** to prevent it from consuming excessive resources during traffic spikes.

#### Why Use Resource Requests & Limits?

✅ **Efficient Resource Management**: Prevents resource hogging and ensures optimal cluster utilization.\
&#x20;✅ **Better Performance**: Guarantees that critical applications always have the required resources.\
&#x20;✅ **Avoids OOM (Out of Memory) Kills**: Helps prevent crashes due to excessive memory usage.\
&#x20;✅ **Fair Scheduling**: Ensures the Kubernetes scheduler places workloads appropriately based on available resources.

#### In My Previous Role

As a **Senior DevOps Engineer**, I ensured all Kubernetes deployments had proper **resource requests and limits** to avoid performance degradation. For example, in a **high-traffic Node.js API**, I set:

* **Requests**: Ensured the service always had enough resources to handle base traffic.
* **Limits**: Prevented excessive resource usage, ensuring stability during peak loads.
* **Monitoring**: Used **Prometheus + Grafana** to fine-tune limits based on actual usage.

#### Example YAML for Resource Requests & Limits

```
apiVersion: v1
kind: Pod
metadata:
  name: resource-demo
spec:
  containers:
    - name: my-app
      image: my-app:latest
      resources:
        requests:
          memory: "256Mi"
          cpu: "250m"
        limits:
          memory: "512Mi"
          cpu: "500m"
```

#### Explanation:

* **requests.memory: “256Mi”** → The container is guaranteed **256MiB** of memory.
* **requests.cpu: “250m”** → The container is guaranteed **0.25 vCPU**.
* **limits.memory: “512Mi”** → The container **cannot** exceed **512MiB** of memory.
* **limits.cpu: “500m”** → The container **cannot** exceed **0.5 vCPU**.

This setup ensures optimal performance while preventing excessive resource usage.

## 🚀 Ready to Master Kubernetes? <a href="#cd7d" id="cd7d"></a>

Take your Kubernetes journey to the next level with the **Master Kubernetes: Zero to Hero course!** 🌟 Whether you’re a beginner or aiming to sharpen your skills, this hands-on course covers:

✅ Kubernetes Basics — Grasp essential concepts like nodes, pods, and services.\
✅ Advanced Scaling — Learn HPA, VPA, and resource optimization.\
✅ Monitoring Tools — Master Prometheus, Grafana, and AlertManager.\
✅ Real-World Scenarios — Build production-ready Kubernetes setups.

🎓 **What You’ll Achieve**

💡 Confidently deploy and manage Kubernetes clusters.\
🛡️ Secure applications with ConfigMaps and Secrets.\
📈 Optimize and monitor resources for peak performance.

🔥 Start Learning Now: \[Join the Master Kubernetes Course]\([**https://cloudops0.gumroad.com/l/k8s**](https://cloudops0.gumroad.com/l/k8s))

Don’t miss your chance to become a Kubernetes expert! 💻✨

🚀 Stay ahead in DevOps and SRE! 🔔 [**Subscribe now**](https://techwithpatil.medium.com/subscribe) and never miss a beat on Kubernetes and more. 🌟
