minikube 在 coredns 时将 dns 显示为 Kubedns

minikube show dns as Kubedns when it is coredns

我在 mac 上安装了 minikube。我看到我有与 minikube 一起使用的 CoreDNS 服务。我通过检查我的 dns 查询结束的 coredns pod 日志确认了这一点。为什么集群信息说我使用的是 Kube-dns 而实际上是 CoreDNS。它是不是我可以忽略的东西,因为它看起来很明显是命名问题!!

我的集群信息如下:

$ kubectl cluster-info
Kubernetes master is running at https://192.168.64.2:8443
KubeDNS is running at https://192.168.64.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

CoreDNS pod 日志

2020-02-14T14:33:49.106Z [INFO] 172.17.0.4:46239 - 734 "A IN hello-world-77b74d7cc8-6t5wt.default.svc.cluster.local. udp 72 false 512" NXDOMAIN qr,aa,rd 165 0.000177567s
2020-02-14T17:10:21.597Z [INFO] 172.17.0.4:52399 - 22998 "A IN hello-world-77b74d7cc8-6t5wt.cluster.local.default.svc.cluster.local. udp 86 false 512" NXDOMAIN qr,aa,rd 179 0.008847724s
2020-02-14T17:10:21.605Z [INFO] 172.17.0.4:59674 - 3370 "A IN hello-world-77b74d7cc8-6t5wt.cluster.local.cluster.local. udp 74 false 512" NXDOMAIN qr,aa,rd 167 0.000221285s
2020-02-14T17:10:21.606Z [INFO] 172.17.0.4:39439 - 62070 "A IN hello-world-77b74d7cc8-6t5wt.cluster.local. udp 60 false 512" NXDOMAIN qr,aa,rd 153 0.000156948s
2020-02-14T17:10:30.699Z [INFO] 172.17.0.4:42925 - 36746 "A IN hello-world-77b74d7cc8-6t5wt.svc.cluster.local.cluster.local. udp 78 false 512" NXDOMAIN qr,aa,rd 171 0.00038

Minikube 版本

$ minikube version
minikube version: v1.5.2
commit: 792dbf92a1de583fcee76f8791cff12e0c9440ad-dirty

界面列表显示如下信息:

$ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 5a:2f:e8:1f:d2:c6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.64.2/24 brd 192.168.64.255 scope global dynamic eth0
       valid_lft 55045sec preferred_lft 55045sec
    inet6 fe80::582f:e8ff:fe1f:d2c6/64 scope link 
       valid_lft forever preferred_lft forever

什么时候对 minikube 进行 ssh 我看到了进程和

$ sudo ps aux | grep dns
root      2541 12.8  4.3 1357844 86832 ?       Ssl  10:11  83:44 /var/lib/minikube/binaries/v1.16.2/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=docker --fail-swap-on=false --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.64.2 --pod-manifest-path=/etc/kubernetes/manifests
root      3565  0.4  1.1 146036 23192 ?        Ssl  10:11   3:14 /coredns -conf /etc/coredns/Corefile
root      3572  0.4  1.1 146036 22768 ?        Ssl  10:11   3:07 /coredns -conf /etc/coredns/Corefile
docker   12531  0.0  0.0  11408   556 pts/0    S+   21:03   0:00 grep dns

当我看 pods 运行

$ kubectl get pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-5644d7b6d9-mkcgk           1/1     Running   1          70d
coredns-5644d7b6d9-q4jr9           1/1     Running   1          70d
etcd-minikube                      1/1     Running   2          70d
kube-addon-manager-minikube        1/1     Running   1          70d
kube-apiserver-minikube            1/1     Running   2          70d
kube-controller-manager-minikube   1/1     Running   2          26h
kube-proxy-7qp8b                   1/1     Running   1          70d
kube-scheduler-minikube            1/1     Running   5          70d
storage-provisioner                1/1     Running   3          70d

Update after I looked at the deployment manifest of CoreDNS following Shahed's answer

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "3"
  creationTimestamp: "2019-12-06T19:47:59Z"
  generation: 5
  labels:
    k8s-app: kube-dns
  name: coredns
  namespace: kube-system
  resourceVersion: "10113"
  selfLink: /apis/apps/v1/namespaces/kube-system/deployments/coredns
  uid: ba1ef689-fe70-4e48-9e6f-5f659226722f
spec:
  progressDeadlineSeconds: 600
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: kube-dns
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        k8s-app: kube-dns
    spec:
      containers:
      - args:
        - -conf
        - /etc/coredns/Corefile
        image: k8s.gcr.io/coredns:1.6.2
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 5
          httpGet:
            path: /health
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        name: coredns
        ports:
        - containerPort: 53

CoreDNS 是 Kubernetes 1.11 的默认设置。对于以前的安装,它是 kube-dns。

因此,根据您的终端输出,这些是正确的。您的 minikube 正在使用 CoreDNS pods 来提供服务。

Is it something that I could ignore as it looks plainly naming issue!!

你完全正确。这是一个命名 问题

为了兼容性,现有客户端从kube-dns迁移到CoreDNS后,仍然可以使用服务名称kube-dns访问服务.