lework/kainstall

dns有问题

jdxia opened this issue · 3 comments

jdxia commented

service创建成功后, nslookup 查这个service查不到. 系统默认的也是.
看coredns日志发现是正常的

你给的信息太少,可以把操作过程记录下来,这样我才了解你的问题。

jdxia commented

Information as of: 2021-05-04 22:06:14

Product............: Alibaba Cloud ECS pc-i440fx-2.1
OS.................: CentOS Linux release 7.8.2003 (Core)
Kernel.............: Linux 3.10.0-1127.19.1.el7.x86_64 x86_64 GNU/Linux
CPU................: Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz 2P 1C 2L

Hostname...........: k8s-master-node1
IP Addresses.......: 172.16.221.206

Uptime.............: 1 days, 09h 37m 43s
Memory.............: 1.18GiB of 3.52GiB RAM used (33.42%)
Load Averages......: 0.12 / 0.29 / 0.26 with 2 core(s) at 2500.002Hz
Disk Usage.........: 6.4G of 40G disk space used (17%)

Users online.......: 1
Running Processes..: 108
Container Info.....: Exited:9 Running:6 Images:13

[root@k8s-master-node1 ~]# kubectl get svc -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
ingress-demo-app ClusterIP 10.96.20.89 80/TCP 33h app=ingress-demo-app
kubernetes ClusterIP 10.96.0.1 443/TCP 33h
[root@k8s-master-node1 ~]# nslookup kubernetes
Server: 100.100.2.136
Address: 100.100.2.136#53

** server can't find kubernetes: NXDOMAIN
[root@k8s-master-node1 ~]# kubectl logs -f -n kube-system coredns-8496bbfb78-6kqtv
.:53
[INFO] plugin/reload: Running configuration MD5 = db32ca3650231d74073ff4cf814959a7
CoreDNS-1.7.0
linux/amd64, go1.14.4, f59c03d
^C
[root@k8s-master-node1 ~]# kubectl logs -f -n kube-system coredns-8496bbfb78-cp4bx
.:53
[INFO] plugin/reload: Running configuration MD5 = db32ca3650231d74073ff4cf814959a7
CoreDNS-1.7.0
linux/amd64, go1.14.4, f59c03d
^C
[root@k8s-master-node1 ~]# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-master-node1 Ready control-plane,master 33h v1.20.4 172.16.221.206 CentOS Linux 7 (Core) 3.10.0-1127.19.1.el7.x86_64 docker://20.10.6
k8s-master-node2 Ready control-plane,master 33h v1.20.4 172.16.221.209 CentOS Linux 7 (Core) 3.10.0-1127.19.1.el7.x86_64 docker://20.10.6
k8s-master-node3 Ready control-plane,master 33h v1.20.4 172.16.221.207 CentOS Linux 7 (Core) 3.10.0-1127.19.1.el7.x86_64 docker://20.10.6
k8s-worker-node1 Ready worker 33h v1.20.4 172.16.221.210 CentOS Linux 7 (Core) 3.10.0-1127.19.1.el7.x86_64 docker://20.10.6
k8s-worker-node2 Ready worker 33h v1.20.4 172.16.221.208 CentOS Linux 7 (Core) 3.10.0-1127.19.1.el7.x86_64 docker://20.10.6
[root@k8s-master-node1 ~]# cat /etc/resolv.conf
options timeout:2 attempts:3 rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
nameserver 100.100.2.136
nameserver 100.100.2.138

看你执行的过程,你这个是在宿主机上解析k8s的域名信息,而你宿主机配置的是外部dns,所以解析不出来。你可以在pod里面nslookup。或者你宿主机配置coredns的地址。