<p>I'd like to keep the number of cores in my GKE cluster below 3.  This becomes much more feasible if the CPU limits of the K8s replication controllers and pods are reduced from 100m to at most 50m.  Otherwise, the K8s pods alone take 70% of one core.</p>

<p>I decided against increasing the CPU power of a node.  This would be conceptually wrong in my opinion because the CPU limit is defined to be measured in cores.  Instead, I did the following:</p>

<ul>
<li>replacing limitranges/limits with a version with "50m" as default CPU limit (not necessary, but in my opinion cleaner)</li>
<li>patching all replication controller in the kube-system namespace to use 50m for all containers</li>
<li>deleting their pods</li>
<li>replacing all non-rc pods in the kube-system namespace with versions that use 50m for all containers</li>
</ul>

<p>This is a lot of work and probably fragile.  Any further changes in upcoming versions of K8s, or changes in the GKE configuration, may break it.</p>

<p>So, is there a better way?</p>

<p>I have found one of the best ways to reduce the system resource requests on a GKE cluster,  is to use a <a href="https://github.com/kubernetes/autoscaler/commits/master/vertical-pod-autoscaler" rel="noreferrer">vertical autoscaler</a>.</p>

<p>Here are the VPA definitions I have used:</p>

<pre><code>apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  namespace: kube-system
  name: kube-dns-vpa
spec:
  targetRef:
    apiVersion: "extensions/v1beta1"
    kind: Deployment
    name: kube-dns
  updatePolicy:
    updateMode: "Auto"

---

apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  namespace: kube-system
  name: heapster-vpa
spec:
  targetRef:
    apiVersion: "extensions/v1beta1"
    kind: Deployment
    name: heapster-v1.6.0-beta.1
  updatePolicy:
    updateMode: "Initial"

---

apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  namespace: kube-system
  name: metadata-agent-vpa
spec:
  targetRef:
    apiVersion: "extensions/v1beta1"
    kind: DaemonSet
    name: metadata-agent
  updatePolicy:
    updateMode: "Initial"

---

apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  namespace: kube-system
  name: metrics-server-vpa
spec:
  targetRef:
    apiVersion: "extensions/v1beta1"
    kind: Deployment
    name: metrics-server-v0.3.1
  updatePolicy:
    updateMode: "Initial"

---

apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  namespace: kube-system
  name: fluentd-vpa
spec:
  targetRef:
    apiVersion: "extensions/v1beta1"
    kind: DaemonSet
    name: fluentd-gcp-v3.1.1
  updatePolicy:
    updateMode: "Initial"

---

apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  namespace: kube-system
  name: kube-proxy-vpa
spec:
  targetRef:
    apiVersion: "extensions/v1beta1"
    kind: DaemonSet
    name: kube-proxy
  updatePolicy:
    updateMode: "Initial"
</code></pre>

<p><a href="https://i.stack.imgur.com/I65kb.png" rel="noreferrer">Here is a screenshot of what it does to a <code>kube-dns</code> deployment.</a></p>
