Kubernetes dns external resources Kubernetes dns external resources kubernetes kubernetes

Kubernetes dns external resources


What are the results of nslookup google.com in the container and the node?

If the pod's dnsPolicy is ClusterFirst, google.com DNS query should be forwarded to the upstream DNS which the node specified.

It would be also useful to show the kube-dns container config and logs.

Default lookup flow


We are working on this quirk as well. silverfox already mentioned the "dnsPolicy" -- by default the pod is configured to inherit the dns configuration from the hosting node.

I have yet to try it (we control our pod spec via an api), but apparently you can override this by specifying the Pods dnsPolicy as "None" in the pod yaml. You need to customize the config for the pod with dnsConfig.

in the yml:

spec:   dnsPolicy: None   dnsConfig:     nameservers:       - 1.1.1.1       - 8.8.8.8

The doc is pretty well written: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/


The kubernetes is unable to access your local node DNS server.You can manually configure it to do so, using the following commands.

Edit the CoreDNS configuration:kubectl -n kube-system edit configmap coredns

Change the line: forward . /etc/resolve.conf {to: forward . 8.8.8.8 {

Restart the CoreDNS pods:kubectl --namespace=kube-system delete pod -l k8s-app=kube-dns

See more details in:https://runkiss.blogspot.com/2021/01/kubernetes-coredns-external-resolving.html