<p>I'm using an AKS cluster running with K8s v1.16.15.</p>
<p>I'm following this simple example to assign some cpu to a pod and it does not work.
<a href="https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/</a></p>
<p>After applying this yaml file for the request,</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: cpu-demo
  namespace: cpu-example
spec:
  containers:
  - name: cpu-demo-ctr
    image: vish/stress
    resources:
      limits:
        cpu: &quot;1&quot;
      requests:
        cpu: &quot;0.5&quot;
    args:
    - -cpus
- &quot;2&quot;
</code></pre>
<p>If I try Kubectl describe pod... I get the following:</p>
<pre><code>Events:
Type     Reason            Age        From               Message
----     ------            ----       ----               -------
Warning  FailedScheduling  &lt;unknown&gt;   default-scheduler  0/1 nodes are available: 1 Insufficient cpu.
</code></pre>
<p>But CPUs seems available, if I run kubectl top nodes, I get:</p>
<pre><code>CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%

702m         36%    4587Mi          100%
</code></pre>
<p>Maybe it is related to some AKS configuration but I can figure it out.</p>
<p>Do you have an idea of what is happening?</p>
<p>Thanks a lot in advance!!</p>

David N
<p>The previous answer well explains the reasons why this could happen. What can be added is that while scheduling pods that has request you have to be aware of the resources that your other cluster objects consumes. System objects also use your resources.  Even with small cluster you may have enabled some addon that will consume node resources.</p>
<p>So your node has a certain amount of CPU and memory it can allocate to pods. While scheduling the Scheduler will only take into consideration nodes with enough unallocated resources to meet your desired requests.
If the amount of unallocated CPU or memory is less than what the pod requests, Kubernetes will not schedule the pod to that node, because the node can’t provide the minimum amount required by the pod.</p>
<p>If you describe your node you will see the pods that are already running and consuming your resources and all <code>allocated resources</code>:</p>
<pre class="lang-sh prettyprint-override"><code>Namespace                   Name                                           CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
  ---------                   ----                                           ------------  ----------  ---------------  -------------  ---
  default                     elasticsearch-master-0                         1 (25%)       1 (25%)     2Gi (13%)        4Gi (27%)      8d
  default                     test-5487d9b57b-4pz8v                          0 (0%)        0 (0%)      0 (0%)           0 (0%)         27d
  kube-system                 coredns-66bff467f8-rhbnj                       100m (2%)     0 (0%)      70Mi (0%)        170Mi (1%)     35d
  kube-system                 etcd-minikube                                  0 (0%)        0 (0%)      0 (0%)           0 (0%)         16d
  kube-system                 httpecho                                       0 (0%)        0 (0%)      0 (0%)           0 (0%)         34d
  kube-system                 ingress-nginx-controller-69ccf5d9d8-rbdf8      100m (2%)     0 (0%)      90Mi (0%)        0 (0%)         34d
  kube-system                 kube-apiserver-minikube                        250m (6%)     0 (0%)      0 (0%)           0 (0%)         16d
  kube-system                 kube-controller-manager-minikube               200m (5%)     0 (0%)      0 (0%)           0 (0%)         35d
  kube-system                 kube-scheduler-minikube                        100m (2%)     0 (0%)      0 (0%)           0 (0%)         35d
  kube-system                 traefik-ingress-controller-78b4959fdf-8kp5k    0 (0%)        0 (0%)      0 (0%)           0 (0%)         34d

Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests      Limits
  --------           --------      ------
  cpu                1750m (43%)   1 (25%)
  memory             2208Mi (14%)  4266Mi (28%)
  ephemeral-storage  0 (0%)        0 (0%)
  hugepages-1Gi      0 (0%)        0 (0%)
  hugepages-2Mi      0 (0%)        0 (0%)

</code></pre>
<p>Now the most important part is what you can do about that:</p>
<ol>
<li>You can enable <a href="https://azure.microsoft.com/en-gb/updates/generally-available-aks-cluster-autoscaler/" rel="nofollow noreferrer">autoscaling</a> so that system automatically provision node and extra needed resources. This of course assumes that you ran out of resources and you need more</li>
<li>You can provision appropriate node by yourself (depending on how did you bootstrap your cluster)</li>
<li>Turn off any addon services that might taking desired resources that you don`t need</li>
</ol>
