Search code examples
kubernetesdnskubernetes-ingressnginx-ingresscoredns

How to Add Internal DNS Records in Kubernetes


I'm currently setting up a Kubernetes cluster where both private and public services are run. While public services should be accessible via the internet (and FQDNs), private services should not (the idea is to run a VPN inside the cluster where private services should be accessible via simple FQDNs).

At the moment, I'm using nginx-ingress and configure Ingress resources where I set the hostname for public resources. external-dns then adds the corresponding DNS records (in Google CloudDNS) - this already works.

The problem I'm facing now: I'm unsure about how I can add DNS records in the same way (i.e. simply specifying a host in Ingress definitions and using some ingress-class private), yet have these DNS records only be accessible from within the cluster.

I was under the impression that I can add these records to the Corefile that CoreDNS is using. However, I fail to figure out how this can be automated.

Thank you for any help!


Solution

  • I managed to resolve the problem myself... wrote a little Go application which watches Ingress resources and adds rewrite rules to the Corefile read by CoreDNS accordingly... works like a charm :)

    PS: If anyone wants to use the tool, let me know. I'm happy to make it open-source if there is any demand.