Resolve custom dns in kubernetes cluster (AKS)

4/10/2019

We currently have pods in a kubernetes cluster (AKS) that need to resolve two different domains.

The first domain beeing the cluster domain default.svc.cluster.local and the second one beeing mydns.local

how can this be achieved?

-- Lycrosa
azure-aks
coredns
dns
kube-dns
kubernetes

3 Answers

4/10/2019

I think you can use ingress and ingress controller to manage the domain and path.with ingress you can manage multiple domain and attch service to particular domain.

https://kubernetes.github.io/ingress-nginx/

Here also sharing tutorial to setup ingress from digital ocean you can follow it :

https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes

-- Harsh Manvar
Source: StackOverflow

5/5/2020

Your second point "2.Modify the coreDNS settings in your AKS cluster with the following json :"

Note that the "forward" plugin should be used in place of "proxy" as noted here:

https://github.com/Azure/AKS/issues/1304

-- Mordecai
Source: StackOverflow

4/12/2019

I found the solution myself.

There are two ways to achieve the desired name resolution:

  1. If your AKS Cluster is within an Azure VNET you can set the DNS settings in the VNET to the custom DNS Server that is able to resolve your custom domain. If your Pods have no specified dns settings then the resolution will work this way:

First the Pods try to resolve the DNS request within CoreDNS, if they can't then they take the DNS settings of the host and ask the DNS Server configured in the host. Since in azure the DNS settings of the VNET are applied to the Virtual Machines it will ask the correct DNS server.

  1. Modify the coreDNS settings in your AKS cluster with the following json :

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: coredns-custom
      namespace: kube-system
    data:
      yourdns.server: |
        yourdns.com:53 {
          errors
          cache 1
          proxy . 10.1.0.40
        }
    

Important to know is, that in AKS you can't overwrite the coredns ConfigMap. The Kubernetes master will always reset it to the default after a couple of seconds. If you want to edit the ConfigMap in AKS you have to name the configmap "coredns-custom".

yourdns.server is actually not the server. It is the domain.server. The DNS server IP is behind the proxy setting.

-- Lycrosa
Source: StackOverflow