首页 > Web开发 > 详细

Kubernetes 中配置私有 DNS 和上游域名服务器(coredns forward)

时间:2020-04-01 23:30:04      阅读:414      评论:0      收藏:0      [点我收藏+]
1.要修改 CoreDNS ConfigMap 并添加条件转发服务器配置

强制所有非集群 DNS 查找通过特定的域名服务器(位于172.16.0.1),将 proxy 和 forward 指向域名服务器,而不是 /etc/resolv.conf。

如果集群的 Consul 域服务器位于 10.150.0.1,并且所有 Consul 名称都带有后缀.consul.local

$ kubectl -n kube-system edit configmap coredns

输出内容如下:

apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
  labels:
    eks.amazonaws.com/component: coredns
    k8s-app: kube-dns
  name: coredns
  namespace: kube-system
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream 172.16.0.1
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        proxy . 172.16.0.1
        cache 30
        loop
        reload
        loadbalance
    }
    domain-name:53 {
        errors 
        cache 30
        forward . custom-dns-server
        reload
    }
     consul.local:53 {
        errors
        cache 30
        proxy . 10.150.0.1
    }

注意:将域名替换为您的域名。将 custom-dns-server 替换为您的自定义 DNS 服务器 IP 地址。

2.验证域名解析方法

$ kubectl run busybox --restart=Never --image=busybox -- sleep 3600
$ kubectl exec busybox -- nslookup domain-name

Kubernetes 中配置私有 DNS 和上游域名服务器(coredns forward)

原文:https://blog.51cto.com/foxhound/2483880

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!