How to expose Kubernetes DNS externally

4/24/2019

Is it possible for an external DNS server to resolve against the K8s cluster DNS? I want to have applications residing outside of the cluster be able to resolve the container DNS names?

-- Chris
kubernetes

3 Answers

4/24/2019

I've never done that, but technically this should be possible by exposing kube-dns service as NodePort. Then you should configure your external DNS server to forward queries for Kube DNS zone "cluster.local" (or any other you have in Kube) to kube-dns address and port.

In Bind that can be done like that:

zone "cluster.local" {
 type forward;
 forward only;
 forwarders{ ANY_NODE_IP port NODEPORT_PORT; };
};
-- Vasily Angapov
Source: StackOverflow

4/24/2019

It's possible, there's a good article proving the concept: https://blog.heptio.com/configuring-your-linux-host-to-resolve-a-local-kubernetes-clusters-service-urls-a8c7bdb212a7

However, I agree with Dan that exposing via service + ingress/ELB + external-dns is a common way to solve this. And for dev purposes I use https://github.com/txn2/kubefwd which also hacks name resolution.

-- Max Lobur
Source: StackOverflow

4/24/2019

Although it may be possible to expose coredns and thus forward requests to kubernetes, the typical approach I've taken, in aws, is to use the external-dns controller.

This will sync services and ingresses with provides like aws. It comes with some caveats, but I've used it successfully in prod environments.

-- Dan Murphy
Source: StackOverflow