<p>What memory does this refer to in k8s? Is this shared total memory for all containers within a
cluster? Or is this per container?</p>
<p>If I have 9 replicas, and my cluster is at 2GB of memory, how much headroom do I have?</p>
<p>What is the difference between requests and limits?</p>
<pre><code>resources:
      requests:
        cpu: 6000m
        memory: 12Gi
      limits:
        cpu: 6000m
        memory: 12Gi
</code></pre>

L P
<p><code>requests</code> and <code>limits</code> are defined at container level. Hence they are per container.</p>
<p>If the node where a Pod is running has enough of a resource available, it's possible (and allowed) for a container to use more resource than its request for that resource specifies. However, a container is not allowed to use more than its resource limit.</p>
<p>For example, if you set a memory request of 256 MiB for a container, and that container is in a Pod scheduled to a Node with 8GiB of memory and no other Pods, then the container can try to use more RAM.</p>
<p>If you set a memory limit of 4GiB for that Container, the kubelet (and container runtime ) enforce the limit. The runtime prevents the container from using more than the configured resource limit. For example: when a process in the container tries to consume more than the allowed amount of memory, the system kernel terminates the process that attempted the allocation, with an out of memory (OOM) error.</p>
<p>When you create a Pod, the Kubernetes scheduler selects a node for the Pod to run on. Each node has a maximum capacity for each of the resource types: the amount of CPU and memory it can provide for Pods. The scheduler ensures that, for each resource type, the sum of the resource requests of the scheduled Containers is less than the capacity of the node. Note that although actual memory or CPU resource usage on nodes is very low, the scheduler still refuses to place a Pod on a node if the capacity check fails. This protects against a resource shortage on a node when resource usage later increases, for example, during a daily peak in request rate</p>
<p>If a Container exceeds its memory limit, it might be terminated. If it is restartable, the kubelet will restart it, as with any other type of runtime failure.</p>
<p>If a Container exceeds its memory request, it is likely that its Pod will be evicted whenever the node runs out of memory.</p>
<p>A Container might or might not be allowed to exceed its CPU limit for extended periods of time. However, it will not be killed for excessive CPU usage</p>
