How to set the number of CPU cores shown to a pod

8/2/2018

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?

-- kawty
kubernetes

1 Answer

8/2/2018

As detailed in documentation here the 1 cpu in is equivalent to:

  • 1 AWS vCPU
  • 1 GCP Core
  • 1 Azure vCore
  • 1 Hyperthread on a bare-metal Intel processor with Hyperthreading

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"
-- Vishal Biyani
Source: StackOverflow