Every container may ask for a share of the node before it runs. That share is its request.
containers:
- name: api
image: stackmonsters/monster-market-api
resources:
requests:
cpu: 250m
memory: 64Mi250m is a quarter of a core; 64Mi is 64 mebibytes. The units matter: cpu: 1 is a whole core, memory: 64M is 64 megabytes, slightly less than 64Mi.
What the scheduler does with it
A node has an Allocatable amount of CPU and memory. The scheduler sums the requests of every Pod already placed on the node and only picks it when the new Pod's requests still fit.
A Pod that fits nowhere is not rejected. It stays Pending and the scheduler keeps trying:
Warning FailedScheduling 0/1 nodes are available: 1 Insufficient cpu.Delete or shrink something and it schedules on its own.
A request is not a cap
The container may use more CPU than it requested if the node has spare. The request only decides placement. The cap is the limit, which is the next lesson.
Reading the node
kubectl describe node shallows-node-1Allocatable:
cpu: 2
memory: 3917912Ki
Allocated resources:
Resource Requests Limits
cpu 850m (42%) 0 (0%)
memory 320Mi (8%) 0 (0%)Allocated resources is the sum of requests, not of usage. kubectl top pods shows usage; the two often disagree, and that gap is what the autoscaler lesson measures.