I'm using Kubernetes v1.0.6 on AWS that has been deployed using kube-up.sh
.
Cluster is using kube-dns
.
$ kubectl get svc kube-dns --namespace=kube-system
NAME LABELS SELECTOR IP(S) PORT(S)
kube-dns k8s-app=kube-dns,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeDNS k8s-app=kube-dns 10.0.0.10 53/UDP
Which works fine.
$ kubectl exec busybox -- nslookup kubernetes.default
Server: 10.0.0.10
Address 1: 10.0.0.10 ip-10-0-0-10.eu-west-1.compute.internal
Name: kubernetes.default
Address 1: 10.0.0.1 ip-10-0-0-1.eu-west-1.compute.internal
This is the resolv.conf
of a pod.
$ kubectl exec busybox -- cat /etc/resolv.conf
nameserver 10.0.0.10
nameserver 172.20.0.2
search default.svc.cluster.local svc.cluster.local cluster.local eu-west-1.compute.internal
Is it possible to have the containers use an additional nameserver?
I have a secondary DNS based service discovery Oon let's say 192.168.0.1) that I would like my kubernetes containers to be able to use for dns resolution.
ps. A kubernetes 1.1 solution would also be acceptable :)
Thank you very much in advance, George
The DNS addon README has some details on this. Basically, the pod will inherit the
resolv.conf
setting of the node it is running on, so you could add your extra DNS server to the nodes'/etc/resolv.conf
. Thekubelet
also takes a--resolv-conf
argument that may provide a more explicit way for you to inject the extra DNS server. I don't see that flag documented anywhere yet, however.In Kuberenetes (probably) 1.2 we'll be moving to a model where
nameservers
are assumed to be fungible. There are too many resolvers that break when different nameservers serve different subsets of DNS, and there is no real specification here that we can point to.In other words, we'll start dropping the host's nameserver records from the container's merged resolv.conf and making our own DNS server the only
nameserver
line. Our DNS will be able to forward requests to upstream nameservers.I eventually managed to solve this pretty easily by configuring SkyDNS to add an additional nameserver, you can just add the environmental variable
SKYDNS_NAMESERVERS
as defined in the SkyDNS docs in your SkyDNS replication controller. It has minimal impact and does not depend on node changes etc.For those usign Kubernetes
kube-dns
, flag-nameservers
nor environment variableSKYDNS_NAMESERVERS
are no longer avaiable.Now, either you put your name servers on the hosts
resolv.conf
, so DNS is inherited from the node, or you use customresolv.conf
and add it to Kubelet with the flag--resolv-conf
as explained here