K8s:在尝试访问集群外的某个域时如何更改Pod的名称服务器

时间:2019-05-28 18:18:25

标签: kubernetes dns coredns

由于某种原因,诸如4.2.2.1,208.67.220.220之类的名称服务器在中国并不是最佳选择。当pod尝试解析群集外部的域时,守护程序集 nodelocaldns 会抱怨输入/输出超时来解析域名

[ERROR] plugin/errors: 2 checkpoint-api.hashicorp.com. A: read udp 192.168.1.15:35630->4.2.2.1:53: i/o timeout
[ERROR] plugin/errors: 2 checkpoint-api.hashicorp.com. AAAA: read udp 192.168.1.15:37137->4.2.2.2:53: i/o timeout

我在configmap中修改了coredns的核心文件,以使用另一个名称服务器114.114.114.114,但无效。

---
kind: ConfigMap
apiVersion: v1
metadata:
  name: coredns
  namespace: kube-system
  selfLink: "/api/v1/namespaces/kube-system/configmaps/coredns"
  uid: 844355d4-7dd3-11e9-ab0b-0800274131a7
  resourceVersion: '919'
  creationTimestamp: '2019-05-24T03:25:02Z'
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: '{"apiVersion":"v1","data":{"Corefile":".:53
      {\n    errors\n    health\n    kubernetes cluster.local in-addr.arpa ip6.arpa
      {\n      pods insecure\n      upstream /etc/resolv.conf\n      fallthrough in-addr.arpa
      ip6.arpa\n    }\n    prometheus :9153\n    forward . /etc/resolv.conf\n    cache
      30\n    loop\n    reload\n    loadbalance\n}\n"},"kind":"ConfigMap","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"EnsureExists"},"name":"coredns","namespace":"kube-system"}}

'
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream 114.114.114.114
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . 114.114.114.114
        cache 30
        loop
        reload
        loadbalance
    }
    consul:53 {
        errors
        cache 30
        forward . 10.233.5.74
}

那我错过了哪种配置?

1 个答案:

答案 0 :(得分:0)

您可以找到信息here。更精确地:

  

显式强制所有非群集DNS查找通过   172.16.0.1处的特定名称服务器,将代理和上游指向   域名服务器

proxy .  172.16.0.1
upstream 172.16.0.1