Resolve custom dns in kubernetes cluster (AKS)

偶尔善良 提交于 2020-02-05 22:56:37

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/55612141/resolve-custom-dns-in-kubernetes-cluster-aks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!