Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
K8s Scheduling Kubernetes Kubernetes: From Zero to Production Module 6 - Scheduling and Scaling

Resource Requests and Limits in Kubernetes

Reviewed & accurate
AI Summary

What You Will Learn

Beginner

  • How requests and limits work
  • QoS classes
  • Best practices
Terminalyaml
spec:
  containers:
  - name: app
    image: my-app
    resources:
      requests:        # What the scheduler reserves
        cpu: "100m"     # 100 millicores (0.1 CPU)
        memory: "128Mi"
      limits:           # Maximum the container can use
        cpu: "500m"     # 500 millicores (0.5 CPU)
        memory: "256Mi"
Requests vs Limits
Requests = what the scheduler RESERVES (guaranteed). Limits = MAXIMUM the container can use (hard cap). If a container exceeds its memory limit, it gets OOM-killed.

QoS Classes

ClassWhenPriority
Guaranteedrequests = limitsHighest (last to be evicted)
Burstablerequests < limitsMedium
BestEffortNo requests/limitsLowest (first evicted)

Practical Exercise

Create a Pod with requests and limits
Apply and check: kubectl describe pod
Look at QoS class
Try exceeding memory limit (Pod gets OOM-killed)
Check: kubectl get pod -o wide

Key Takeaways

  • Requests: what scheduler reserves. Limits: max allowed.
  • CPU: 100m = 0.1 CPU. Memory: 128Mi = 128 MB.
  • Exceeding memory limit = OOM kill. Exceeding CPU limit = throttled.
  • QoS: Guaranteed (requests=limits) is best.
  • Always set requests and limits in production.
Previously: Lesson 31 covered scheduling.
Today: You learned: Control CPU and memory per container.
Next: Lesson 33 covers HPA.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments