I don't really understand this after reading through the document. Some use a term like "CPU", but some use "core".
I am running Kubernetes in my laptop for testing purpose. My laptop has one CPU (2.2 GHz) and four cores.
If I want to set the CPU request/limit for pod, should the maximum resource that I have be 1000m or 4000m?
What is the difference (CPU vs. core) here in a Kubernetes context?
In Kubernetes, 1 CPU unit is equivalent to 1 physical CPU core, or 1 virtual core, depending on whether the node is a physical host or a virtual machine running inside a physical machine. Fractional requests are allowed. When you define a container with spec.
CPU resources are measured in millicore. If a node has 2 cores, the node's CPU capacity would be represented as 2000m. The unit suffix m stands for “thousandth of a core.” 1000m or 1000 millicore is equal to 1 core. 4000m would represent 4 cores.
memory: 100Mi. cpu: 100m. The unit suffix m stands for “thousandth of a core,” so this resources object specifies that the container process needs 50/1000 of a core (5%) and is allowed to use at most 100/1000 of a core (10%).
It will instead be scheduled to first node, since it has 2 cores. The K8S documentation is a bit vague on this but it states: "A Container might or might not be allowed to exceed its CPU limit for extended periods of time.
To clarify what's described here in the Kubernetes context, 1 CPU is the same as a core (Also more information here).
1000m (milicores) = 1 core = 1 vCPU = 1 AWS vCPU = 1 GCP Core.
100m (milicores) = 0.1 core = 0.1 vCPU = 0.1 AWS vCPU = 0.1 GCP Core.
For example, an Intel Core i7-6700 has four cores, but it has Hyperthreading which doubles what the system sees in terms of cores. So in essence, it will show up in Kubernetes as:
8000m = 8 cores = 8 vCPUs
Some extra information: These resources are managed by the kube-scheduler using the Completely Fair Scheduler (CFS), and there are no guarantees in terms of overruns within the same machine and your pod may be moved around.
If you'd like to have stronger guarantees, you might consider the --cpu-manager-policy=static
(CPU Manager) option in the kubelet. More information is here and here.
For more details on what your system sees as a CPU (and number of CPUs) on a Linux system you can see how many vCPUs you have by running cat /proc/cpuinfo
.
To remove any guesswork regarding your laptop or any other environment, execute:
kubectl get nodes
...and then this for a particular node:
kubectl describe node <node-name>
Look for cpu
under Allocatable (which may have the same value as under 'Capacity').
Take into consideration that
1 CPU = 1000 millicores/millicpu
when setting "fractional" resources.requests.cpu
and resources.limits.cpu
for containers.
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