<p>When creating a cluster on GKE its possible to create <a href="https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type#extendedmemory" rel="noreferrer">Custom Instance Types</a>. When adding <code>8GB</code> of memory to an <code>n1-standard-1</code> Kubernetes only shows memory allocatable of <code>6.37GB</code>. Why is this?</p>

<p>The requested memory includes all the pods in <code>kube-system</code> namespace so where is this extra memory going?</p>

<p>Quotinig from <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture" rel="noreferrer">documentation</a>:</p>

<blockquote>
  <p><strong>Node allocatable resources</strong> </p>
  
  <p><strong>Note</strong> that some of a node's resources are required to run the Kubernetes Engine and Kubernetes resources necessary to make that node function as part of your cluster. As such, you may notice a disparity between your node's total resources (as specified in the machine type documentation) and the node's allocatable resources in Kubernetes Engine</p>
  
  <p><strong>Note</strong>: As larger machine types tend to run more containers (and by extension, Kubernetes pods), the amount of resources that Kubernetes Engine reserves for cluster processes scales upward for larger machines.</p>
  
  <p><strong>Caution</strong>: In Kubernetes Engine node versions prior to 1.7.6, reserved resources were not counted against a node's total allocatable resources. 
  If your nodes have recently upgraded to version 1.7.6, they might appear to have fewer resources available, as Kubernetes Engine now displays allocatable resources. This can potentially lead to your cluster's nodes appearing overcommitted, and you might want to resize your cluster as a result.</p>
</blockquote>

<p>For example performing some tests you can doublecheck:</p>

<pre><code>Machine type            Memory(GB)  Allocatable(GB) CPU(cores)  Allocatable(cores)

g1-small                     1.7        1.2          0.5         0.47
n1-standard-1 (default)      3.75       2.7          1           0.94
n1-standard-2                7.5        5.7          2           1.93
n1-standard-4               15         12            4           3.92
n1-standard-8               30         26.6          8           7.91
n1-standard-16              60         54.7         16          15.89
</code></pre>

<blockquote>
  <p><strong>Note</strong>: The values listed for allocatable resources do not account for the resources used by kube-system pods, the amount of which varies with each Kubernetes release. These system pods generally occupy an additional 400m CPU and 400mi memory on each node (values are approximate). It is recommended that you directly inspect your cluster if you require an exact accounting of usable resources on each node.</p>
</blockquote>

<h2>UPDATE</h2>

<p>There is also the official explanation from the Kubernetes Documentation regarding why this resources are used:</p>

<blockquote>
  <p>kube-reserved is meant to capture resource reservation for kubernetes system daemons like the kubelet, container runtime, node problem detector, etc. <strong>It is not meant to reserve resources for system daemons</strong> that are run as pods. kube-reserved is typically a function of pod density on the nodes. This performance dashboard exposes cpu and memory usage profiles of kubelet and docker engine at multiple levels of pod density. This blog post explains how the dashboard can be interpreted to come up with a suitable kube-reserved reservation.</p>
</blockquote>

<p>I would suggest you to go thorugh <a href="https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable" rel="noreferrer">this</a> page if you are interested to learn more.</p>
