flakes
flakes

Reputation: 23664

Update default search domains in pods

When I exec into a container I see an /etc/resolv.conf file that looks like this:

$ cat /etc/resolv.conf
search namespace.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.43.0.10
options ndots:5

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 foo.com and bar.com by default for any pod how can I update the search line to look like bellow?

search namespace.svc.cluster.local svc.cluster.local cluster.local foo.com bar.com

Notes:

Upvotes: 1

Views: 2093

Answers (1)

flakes
flakes

Reputation: 23664

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

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 /etc/resolv.conf was being replaced by a new file on the node. I was able to circumvent this issues by supplying --resolv-conf where the files looks like this:

$ cat /somedir/resolv.conf
search foo.com bar.com
nameserver 8.8.8.8

Then start the server with /bin/k3s server --resolv-conf=/somedir/resolv.conf

Now when pods are spawned, k3s will parse this file for the search line and automatically append the search domains to whatever pod is created.

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!

Upvotes: 2

Related Questions