In this scenario, you will:
- Create a Pod with CPU/memory requests (minimum guaranteed)
- Set limits (maximum allowed)
- Verify how Kubernetes schedules and restricts resource usage
- Inspect assigned resources in running Pod
This is a core Kubernetes skill that every DevOps/SRE must master.
โ Step 1 โ Create a Pod With Resource Requests & Limits
Create file:
# resources-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: resource-demo
spec:
containers:
- name: nginx
image: nginx:1.25
resources:
requests:
memory: "128Mi"
cpu: "100m" # 0.1 CPU core
limits:
memory: "256Mi"
cpu: "500m" # 0.5 CPU core
ports:
- containerPort: 80
Apply:
kubectl apply -f resources-pod.yaml
๐งช Step 2 โ Verify Pod Status
kubectl get pod resource-demo -o wide
Pod should be running.
๐ Step 3 โ Inspect Resource Configuration
Run:
kubectl describe pod resource-demo
Look for:
Limits:
cpu: 500m
memory: 256Mi
Requests:
cpu: 100m
memory: 128Mi
This confirms:
โ Requests = Minimum guaranteed
โ Limits = Maximum allowed
๐ก What This Means in Real Life
- Kubernetes schedules the Pod only on nodes that have 128Mi RAM + 100m CPU free
- The Pod cannot exceed 256Mi RAM or it will be OOMKilled
- The Pod cannot use more than 500m CPU โ throttling will occur
๐งช Step 4 โ Test OOMKill (Optional Challenge)
Exec into the container:
kubectl exec -it resource-demo -- bash
Run a memory stress test (if you have stress inside containerโit won't be there in nginx).
So instead run a simple memory loop:
head -c 300M </dev/zero | tail
Pod will exceed 256Mi โ Kubernetes will kill it with OOMKilled.
Check:
kubectl get pod resource-demo
kubectl describe pod resource-demo | grep -i oom
You'll see:
OOMKilled
๐ป Step 5 โ Clean Up
kubectl delete pod resource-demo
๐ Thanks for reading! If this post added value, a like โค๏ธ, follow, or share would encourage me to keep creating more content.
โ Latchu | Senior DevOps & Cloud Engineer
โ๏ธ AWS | GCP | โธ๏ธ Kubernetes | ๐ Security | โก Automation
๐ Sharing hands-on guides, best practices & real-world cloud solutions



Top comments (0)