解决Kubernetes集群(AKS)中的自定义DNS [英] Resolve custom dns in kubernetes cluster (AKS)

查看:261
本文介绍了解决Kubernetes集群(AKS)中的自定义DNS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前在kubernetes集群(AKS)中具有需要解析两个不同域的Pod.

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

第一个域为群集域default.svc.cluster.local,第二个域为mydns.local

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

这怎么实现?

推荐答案

我自己找到了解决方案.

I found the solution myself.

有两种方法可以实现所需的名称解析:

There are two ways to achieve the desired name resolution:

  1. 如果AKS群集位于Azure VNET内,则可以将VNET中的DNS设置设置为能够解析自定义域的自定义DNS服务器.如果您的Pod没有指定dns设置,则解析将以这种方式工作:

首先,Pod尝试解析CoreDNS中的DNS请求,如果不能,则采用主机的DNS设置并询问在主机中配置的DNS服务器.由于天蓝色地将VNET的DNS设置应用于虚拟机,因此它将询问正确的DNS服务器.

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. 使用以下json修改AKS集群中的coreDNS设置:

  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
    }

重要的是,在AKS中您不能覆盖coredns ConfigMap. Kubernetes主站将始终在几秒钟后将其重置为默认值.如果要在AKS中编辑ConfigMap,则必须将configmap命名为"coredns-custom".

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实际上不是服务器.它是domain.server. DNS服务器IP位于代理设置的后面.

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

这篇关于解决Kubernetes集群(AKS)中的自定义DNS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆