<p>When I <code>exec</code> into a container I see an <code>/etc/resolv.conf</code> file that looks like this:</p>
<pre><code>$ cat /etc/resolv.conf
search namespace.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.43.0.10
options ndots:5
</code></pre>
<p>How can I append to the search domains for all containers that get deployed such that the search domains will include extra domains? e.g. If I wanted to add <code>foo.com</code> and <code>bar.com</code> <em>by default for any pod</em> how can I update the search line to look like bellow?</p>
<pre><code>search namespace.svc.cluster.local svc.cluster.local cluster.local foo.com bar.com
</code></pre>
<p>Notes:</p>
<ul>
<li><p>This is a self managed k8s cluster. I am able to update the DNS/cluster configuration however I need to. I have already updated the coredns component to resolve my nameservers correctly, but this setting needs to be applied to each pod I would imagine.</p>
</li>
<li><p>I have looked at the pod spec, but this wouldn't be a great solution as it would need to be added to every pods (or deployment/ job/ replicaset/ etc) manifest in the system. I need this to be applied to all pods by default.</p>
</li>
<li><p>Due to the way hostnames are returned in numerous existing services, I cannot reasonably expect hostnames to be fully qualified domain names. This is an effort to maintain backwards compatibility with many services we already have (e.g. an LDAP request might return host <code>fizz</code>, but the lookup will need to fully resolve to <code>fizz.foo.com</code>). This is the way bare metal machines and VMs are normally configured here.</p>
</li>
</ul>

flakes
<p><em>I found a possible solution, but I won't mark this as correct myself, because this was not directly specific to k8s, but rather k3s. I might come back later and provide more</em></p>
<p>In my case my test cluster was a k3s service, which I was assuming would act mostly the same as k8s. The way my environment was set up, my normal <code>/etc/resolv.conf</code> was being replaced by a new file on the node. I was able to circumvent this issues by supplying <code>--resolv-conf</code> where the files looks like this:</p>
<pre><code>$ cat /somedir/resolv.conf
search foo.com bar.com
nameserver 8.8.8.8
</code></pre>
<p>Then start the server with <code>/bin/k3s server --resolv-conf=/somedir/resolv.conf</code></p>
<p>Now when pods are spawned, k3s will parse this file for the <code>search</code> line and automatically append the search domains to whatever pod is created.</p>
<p>I'm not sure if I'm going to run into this issue again when I try this on actual k8s, but at least this gets me back up and running!</p>
