无法解析 kubernetes.default 或服务

Cannot resolve kubernetes.default or services

我无法从 kubernetes 解析服务。

kubectl get pods -l k8s-app=kube-dns --namespace kube-system
NAME                       READY   STATUS    RESTARTS   AGE   IP
coredns-86c58d9df4-gn62b   1/1     Running   0          18d   10.244.0.58
coredns-86c58d9df4-svmk5   1/1     Running   0          18d   10.244.0.59

容器不解析任何域,包括 kubernetes.default

kubectl exec -ti busybox -- sh
/ # nslookup kubernetes.
defaultServer:    10.96.0.10
Address 1: 10.96.0.10

nslookup: can't resolve 'kubernetes.default'
command terminated with exit code 1

来自 dns pods 的日志不显示任何查询(注意 coredns 配置为记录查询)

kubectl logs --namespace=kube-system coredns-86c58d9df4-gn62b
.:53
2019-01-18T21:44:34.271Z [INFO] CoreDNS-1.2.6
2019-01-18T21:44:34.271Z [INFO] linux/amd64, go1.11.2, 756749c
CoreDNS-1.2.6
linux/amd64, go1.11.2, 756749c
 [INFO] plugin/reload: Running configuration MD5 = f65c4821c8a9b7b5eb30fa4fbc167769
[INFO] Reloading
 [INFO] plugin/reload: Running configuration MD5 = 2394cf331ea25e9aacc36ddf69fafcdb
[INFO] Reloading complete
2019-02-04T22:23:21.266Z [INFO] 127.0.0.1:39695 - 58939 "HINFO IN 4718439545634584094.2038959545847864189. udp 57 false 512" NXDOMAIN qr,rd,ra 133 0.021492508s

托管的 kube-node coredns 是 运行 ubuntu xenial。

I noticed there is a known issue on ubuntu hosts

我应用了自定义 kubelet conf,设置 --resolv-conf=/run/systemd/resolve/resolv.conf

❯ systemctl status kubelet.service
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Wed 2019-02-06 01:05:42 GMT; 5min ago
     Docs: https://kubernetes.io/docs/home/
 Main PID: 27867 (kubelet)
    Tasks: 30 (limit: 4915)
   CGroup: /system.slice/kubelet.service
           └─27867 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-drive --resolv-conf=/run/systemd/resolve/resolv.conf

但是我仍然无法解决任何服务。

我删除了 pods,他们的管理员重新安排了他们。

现在 dns 查询和服务发现工作正常。

我不确定 coredns 服务现在是否可以访问,因为我更新了 kubelet --resolve-conf 或者该服务是否只需要重新启动。