'--dns flag equivalent for kubernetes yaml file?
I want the pods that are created in my Kubernetes cluster to be able to use my preexisting custom DNS server.
The DNS is on a separate machine and, when running docker containers, I could set this using the --dns flag.
Is it possible to replicate that in Kubernetes pods?
I am also open to other suggestions on how to do this.
Solution 1:[1]
or you can configure it at a cluster level
More precisely, as in this gist, you can:
Configure kube-dns to use an upstream nameserver instead of the one in
/etc/resolv.conf:Save in
configmap.yml:apiVersion: v1 kind: ConfigMap metadata: name: kube-dns namespace: kube-system data: upstreamNameservers: | ["8.8.8.8"]Then:
kubectl create -f configmap.yml
Official documentation: "CoreDNS configuration equivalent to kube-dn"
Also:
Retrieve nameserver kube-dns is using:
kubectl exec -ti -n kube-system \ $(kubectl get --no-headers=true pods -l k8s-app=kube-dns \ -o custom-columns=:metadata.name -n kube-system) \ -c kubedns -- cat /etc/resolv.conf
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | VonC |
