Kubernetes dns external resources

805 views Asked by At

I installed kubernetes by following this tutorial.

One of my containers tries to get resources from an external domain, such as google.com. But it fails because kubernetes dns doesn't use external name resolving.

How can I configure kubernetes using dns 8.8.8.8 ?

2

There are 2 answers

0
silverfox On BEST ANSWER

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

0
blackstrype On

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/