1

我有以下配置图

kubectl get configmap coredns --namespace kube-system -o yaml
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           upstream
           fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        proxy . /etc/resolv.conf
        cache 30
        reload
    }
kind: ConfigMap
metadata:
  creationTimestamp: 2018-06-29T03:48:35Z
  name: coredns
  namespace: kube-system
  resourceVersion: "222"
  selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
  uid: 4c8c3b17-7b4f-11e8-aaa1-0cc47a453e30

但我看不出它是从哪里获取上游 dns 服务器的。我最初使用 kube-dns 部署了这个 k8s 集群,但在 1.11 出来时更新为 coredns。我的上游服务器设置为 192.168.1.18,但我现在需要更改它。我检查了每个主机的 /etc/resolv.conf,那里没有列出 192.168.1.18,从这个 configmap 中,我也看不到它......但是如果我在 192.168.1.18 上停止 DNS,pod 就会停止对外解决。这个 IP 地址存储在哪里?

4

1 回答 1

0

所以似乎本地dns设置为coredns

/etc/resolv.conf
nameserver 127.0.0.53

如果我查看在 53 上监听的 dns 服务,我会得到这个

kubectl describe svc kube-dns --namespace kube-system
Name:              kube-dns
Namespace:         kube-system
Labels:            k8s-app=kube-dns
                   kubernetes.io/cluster-service=true
                   kubernetes.io/name=KubeDNS
Annotations:       prometheus.io/scrape=true
Selector:          k8s-app=kube-dns
Type:              ClusterIP
IP:                10.96.0.10
Port:              dns  53/UDP
TargetPort:        53/UDP
Endpoints:         10.32.0.12:53,10.32.0.14:53

与 coredns pods 相关。输入时...包含 IP 地址

kubectl exec -it --namespace kube-system coredns-78fcdf6894-l4tph -- sh
/ # cd /etc
/etc # ls
TZ                    fstab                 logrotate.d           os-release            services
alpine-release        group                 modprobe.d            passwd                shadow
apk                   hostname              modules               periodic              shells
ca-certificates       hosts                 modules-load.d        profile               ssl
ca-certificates.conf  init.d                motd                  profile.d             sysctl.conf
conf.d                inittab               mtab                  protocols             sysctl.d
coredns               issue                 network               resolv.conf           udhcpd.conf
crontabs              localtime             opt                   securetty
/etc # cat resolv.conf
nameserver 192.168.1.18
search home

啊。什么皮塔饼

于 2018-07-26T06:43:00.210 回答