<p>I created a Pod (see config below) on k8s (AKS, k8s version 1.19.7) with <code>cpu=&quot;6&quot;</code> and <code>memory=20G</code>. So I expected the Pod to have 6 cores on the CPU as I read on the <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/" rel="nofollow noreferrer">k8s docu</a></p>
<blockquote>
<p>One cpu, in Kubernetes, is equivalent to 1 vCPU/Core for cloud
providers</p>
</blockquote>
<p>When I check <code>lscpu</code> on the container, I get</p>
<pre><code>root@user-ubuntu:/# lscpu
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          16                                  &lt;-- 2x 8 hyperthreading cores?
On-line CPU(s) list:             0-15
Thread(s) per core:              2
Core(s) per socket:              8                               &lt;-- expected 6
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           85
Model name:                      Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz 
</code></pre>
<p>Also, the memory seems to be 32G instead of 20G</p>
<pre><code>root@user-ubuntu:/# vmstat -s -S M
        32114 M total memory
</code></pre>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: user-ubuntu
spec:
  containers:
  - name: user-ubuntu
    image: ubuntu:latest
    command: [&quot;/bin/sleep&quot;, &quot;3650d&quot;]
    imagePullPolicy: IfNotPresent
    resources:
      requests:
        cpu: &quot;6&quot;
        memory: 20G
      limits:
        cpu: &quot;6&quot;
        memory: 20G
    volumeMounts:
    - mountPath: &quot;/mnt/azure&quot;
      name: volume
  restartPolicy: Always
  volumes:
    - name: volume
      persistentVolumeClaim:
        claimName: pvc-user-default
</code></pre>

tenticon
<p>The <code>lscpu</code> command displays kernel resoures, in particular, from <code>/proc/cpuinfo</code> (see <a href="https://linux.die.net/man/1/lscpu" rel="nofollow noreferrer">documentation</a>). Now, all the containers running on host system (which can be a physical machine or a VM) share the same kernel (this is the distinguishing feature of containers vs. VMs). Thus, the information you get from <code>lscpu</code> corresponds to the underlying host and not the container.</p>
<p>Here's a list of references where this issue is discussed:</p>
<ul>
<li><a href="https://news.ycombinator.com/item?id=25213368" rel="nofollow noreferrer">https://news.ycombinator.com/item?id=25213368</a></li>
<li><a href="https://github.com/lxc/lxcfs/issues/181" rel="nofollow noreferrer">https://github.com/lxc/lxcfs/issues/181</a></li>
<li><a href="https://github.com/kubernetes/kubernetes/issues/92904" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/92904</a></li>
<li><a href="https://github.com/kubernetes/kubernetes/issues/53706" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/53706</a></li>
</ul>
<p>Your container is however restricted by a <a href="https://en.wikipedia.org/wiki/Cgroups" rel="nofollow noreferrer">cgroup</a> to the resource usage you defined in the Pod definition. So, even though <code>lscpu</code> displays 16 cores, your container can still only use 6 of them. The same applies for the memory.</p>
