<p>I am deploying a container in Google Kubernetes Engine with this YAML fragment:</p>

<pre><code>    spec:
      containers:
      - name: service
        image: registry/service-go:latest
        resources:
          requests:
           memory: "20Mi"
           cpu: "20m"
          limits:
           memory: "100Mi"
           cpu: "50m"
</code></pre>

<p>But it keeps taking 120m. <strong>Why is "limits" property being ignored?</strong> Everything else is working correctly. If I request 200m, 200m are being reserved, but limit keeps being ignored.</p>

<p><a href="https://i.stack.imgur.com/9zN6j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9zN6j.png" alt="enter image description here"></a></p>

<p>My Kubernetes version is 1.10.7-gke.1</p>

<p>I only have the default namespace and when executing</p>

<blockquote>
  <p>kubectl describe namespace default</p>
</blockquote>

<pre><code>Name:         default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;
Status:       Active

No resource quota.

Resource Limits
 Type       Resource  Min  Max  Default Request  Default Limit  Max Limit/Request Ratio
 ----       --------  ---  ---  ---------------  -------------  -----------------------
 Container  cpu       -    -    100m             -              -
</code></pre>

<h2>Considering Resources Request <strong>Only</strong></h2>

<p>The google cloud console works well, I think you have multiple containers in your pod, this is why. The value shown above is the sum of resources requests declared in your truncated YAML file. You can verify easily with <code>kubectl</code>.</p>

<p>First verify the number of containers in you pod.</p>

<p><code>kubectl describe pod service-85cc4df46d-t6wc9</code> </p>

<p>Then, look the description of the node via kubectl, you should have the same informations as the console says.</p>

<p><code>kubectl describe node gke-default-pool-abcdefgh...</code></p>

<h2>What is the difference between resources request and limit ?</h2>

<p>You can imagine your cluster as a big square box. This is the total of your allocatable resources. When you drop a Pod in the big box, Kubernetes will check if there is an empty space for the requested resources of the pod (is the small box fits in the big box?). If there is enough space available, then it will schedule your workload on the selected node.</p>

<p>Resources limits are not taken into account by the scheduler. All is done at the kernel level with CGroups. The goal is to restrict workloads to take all the CPU or Memory on the node they are scheduled on. </p>

<p>If your resources requests == resources limits then, workloads cannot escape their "box" and are not able to use available CPU/Memory next to them. In other terms, your resource are guaranteed for the pod. </p>

<p>But, if the limits are greater than your requests, this is called overcommiting resources. You bet that all the workloads on the same node are not fully loaded at the same time (generally the case).</p>

<p>I recommend to not overcommiting the memory resource, do not let the pod escape the "box" in term of memory, it can leads to OOMKilling.</p>
