Kubernetes (K8s) (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
Resource Requests vs. Resource Limits (CPU & Memory).
junior LevelCode ExamplekubernetesBasic
In Simple Words:
yaml
resources:
requests:
cpu: "250m" # 0.25 of a CPU core
memory: "512Mi" # 512 Megabytes
limits:
cpu: "1000m" # 1 full CPU core
memory: "1Gi" # 1 Gigabyte
requests(Guaranteed Floor - Used by Scheduler):- The minimum resources guaranteed to the Pod.
- The
kube-schedulerplaces the Pod on a node only if the node has enough unreserved capacity to satisfy the request.
limits(Ceiling - Enforced by Linux Kernel):- CPU Limit: Enforced via CFS quotas. If a container exceeds its CPU limit, the Linux kernel throttles the process; it is NOT killed.
- Memory Limit: Enforced via cgroups. If a container exceeds its memory limit, the Linux kernel immediately terminates it with an OOMKilled error (Exit Code 137).