<p>We have a deployment of Kubernetes in Google Cloud Platform. Recently we hit one of the well known issues related on a problem with the kube-dns that happens at high amount of requests <a href="https://github.com/kubernetes/kubernetes/issues/56903" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/56903</a> (its more related to SNAT/DNAT and contract but the final result is out of service of kube-dns).</p>

<p>After a few days of digging on that topic we found that k8s already have a solution witch is currently in alpha (<a href="https://kubernetes.io/docs/tasks/administer-cluster/nodelocaldns/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/nodelocaldns/</a>)</p>

<p>The solution is to create a caching CoreDNS as a daemonset on each k8s node so far so good.</p>

<p>Problem is that after you create the daemonset you have to tell to kubelet to use it with --cluster-dns option  and we cant find any way to do that in GKE environment. Google bootstraps the cluster with "configure-sh" script in instance metadata. There is an option to edit the instance  template and "hardcode" the required values but that is not an option if you upgrade the cluster  or use the horizontal autoscaling all of the modified values will be lost.
The last idea was to use  custom startup script that pull  configuration and update the metadata server but this is a too complicated task.</p>

<p>As of 2019/12/10, GKE now supports through the <code>gcloud</code> CLI in beta:</p>

<blockquote>
  <h1>Kubernetes Engine</h1>
  
  <ul>
  <li>Promoted NodeLocalDNS Addon to beta. Use <code>--addons=NodeLocalDNS</code> with <code>gcloud beta container clusters create</code>. This addon can be enabled or disabled on existing clusters using <code>--update-addons=NodeLocalDNS=ENABLED</code> or <code>--update-addons=NodeLocalDNS=DISABLED</code> with gcloud container clusters update.</li>
  </ul>
</blockquote>

<p>See <a href="https://cloud.google.com/sdk/docs/release-notes#27300_2019-12-10" rel="nofollow noreferrer">https://cloud.google.com/sdk/docs/release-notes#27300_2019-12-10</a></p>
