containers[].resources.limits.cpu
can limit CPU resources for a pod like:
spec:
containers:
- name: cpu-demo-ctr
image: vish/stress
resources:
limits:
cpu: "1"
requests:
cpu: "0.5"
I'd also like to set the number of CPU cores shown to a pod. Is it possible?
It will instead be scheduled to first node, since it has 2 cores.
This would ideally be the sum of all container requests in a cluster. This value at node level can be retrieved by running kubectl describe node <node-name> command. We used to sum up these values to get total allocated cpu in a cluster.
Each container has a limit of 0.5 CPU and 128MiB of memory. You can say the Pod has a request of 0.5 CPU and 128 MiB of memory, and a limit of 1 CPU and 256MiB of memory.
As detailed in documentation here the 1
cpu in is equivalent to:
So you can request a core using
cpu: "1"
or
cpu: "1000m"
But if you want to be more precise - you can allocate like 250m of a CPU:
cpu: "250m"
Lastly, if you need more than one cpu you could do:
cpu: "2"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With