Comment
Author: Admin | 2025-04-28
I am encountering an issue with Kubernetes where my pods cannot resolve hostnames (such as google.com or kubernetes.default).I currently have 1 master and 1 node running on two CentOS7 instances in OpenStack. I deployed using kubeadm.Here are the versions installed:kubeadm-1.7.3-1.x86_64kubectl-1.7.3-1.x86_64kubelet-1.7.3-1.x86_64kubernetes-cni-0.5.1-0.x86_64The below outlines some verification steps to maybe give some insight into my problem.I define a busybox pod:apiVersion: v1kind: Podmetadata: name: busybox namespace: defaultspec: containers: - image: busybox command: - sleep - "3600" imagePullPolicy: IfNotPresent name: busybox restartPolicy: AlwaysAnd then create the pod:$ kubectl create -f busybox.yamlTry to perform a DNS lookup of name google.com:$ kubectl exec -ti busybox -- nslookup google.comServer: 10.96.0.10Address 1: 10.96.0.10nslookup: can't resolve 'google.com'Try to perform a DNS lookup of the name kubernetes.default:$ kubectl exec -ti busybox -- nslookup kubernetes.defaultServer: 10.96.0.10Address 1: 10.96.0.10nslookup: can't resolve 'kubernetes.default'Check if my DNS pod is running:$ kubectl get pods --namespace=kube-system -l k8s-app=kube-dnsNAME READY STATUS RESTARTS AGEkube-dns-2425271678-k1nft 3/3 Running 9 5dCheck if my DNS service is up:$ kubectl get svc --namespace=kube-systemNAME CLUSTER-IP EXTERNAL-IP PORT(S) AGEkube-dns 10.96.0.10 53/UDP,53/TCP 5dCheck if DNS endpoints are exposed:$ kubectl get ep kube-dns --namespace=kube-systemNAME ENDPOINTS AGEkube-dns 10.244.0.5:53,10.244.0.5:53 5dCheck the contents of /etc/resolv.conf in my container:$ kubectl exec -ti busybox -- cat /etc/resolv.confnameserver 10.96.0.10search default.svc.cluster.local svc.cluster.local cluster.localoptions ndots:5If I understand correctly, the Kubernetes documentation states that my pods should inherit the DNS configurations of the node (or master?). However, even with just one line in it (nameserver 10.92.128.40), I receive the below warning when spinning up a pod:Search Line limits were exceeded, some DNS names were omitted, and the applied search line is:default.svc.cluster.local svc.cluster.local cluster.local mydomain.net anotherdomain.net yetanotherdomain.netI understand there exists a known issue where only so many items can be listed in /etc/resolv.conf. However, where would the above search line and nameserver in my container be generated from?Finally here are the logs from the kube-dns container:$ kubectl logs --namespace=kube-system $(kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o name) -c kubednsI0817 20:54:58.445280 1 dns.go:48] version: 1.14.3-4-gee838f6I0817 20:54:58.452551 1 server.go:70] Using configuration read from directory: /kube-dns-config with period 10sI0817 20:54:58.452616 1 server.go:113] FLAG: --alsologtostderr="false"I0817 20:54:58.452628 1 server.go:113] FLAG: --config-dir="/kube-dns-config"I0817 20:54:58.452638 1 server.go:113] FLAG: --config-map=""I0817 20:54:58.452643 1 server.go:113] FLAG: --config-map-namespace="kube-system"I0817 20:54:58.452650 1 server.go:113] FLAG: --config-period="10s"I0817 20:54:58.452659 1 server.go:113] FLAG: --dns-bind-address="0.0.0.0"I0817 20:54:58.452665 1 server.go:113] FLAG: --dns-port="10053"I0817 20:54:58.452674 1 server.go:113] FLAG: --domain="cluster.local."I0817 20:54:58.452683 1 server.go:113] FLAG: --federations=""I0817 20:54:58.452692 1 server.go:113] FLAG: --healthz-port="8081"I0817 20:54:58.452698 1 server.go:113] FLAG: --initial-sync-timeout="1m0s"I0817 20:54:58.452704 1 server.go:113] FLAG: --kube-master-url=""I0817 20:54:58.452713 1 server.go:113] FLAG: --kubecfg-file=""I0817 20:54:58.452718 1 server.go:113] FLAG: --log-backtrace-at=":0"I0817 20:54:58.452727 1 server.go:113] FLAG: --log-dir=""I0817 20:54:58.452734 1 server.go:113] FLAG: --log-flush-frequency="5s"I0817 20:54:58.452741 1 server.go:113] FLAG: --logtostderr="true"I0817 20:54:58.452746 1 server.go:113] FLAG: --nameservers=""I0817 20:54:58.452752 1 server.go:113] FLAG: --stderrthreshold="2"I0817 20:54:58.452759 1 server.go:113] FLAG: --v="2"I0817 20:54:58.452765 1 server.go:113] FLAG: --version="false"I0817 20:54:58.452775 1 server.go:113] FLAG: --vmodule=""I0817 20:54:58.452856 1 server.go:176] Starting SkyDNS server (0.0.0.0:10053)I0817 20:54:58.453680 1 server.go:198] Skydns metrics enabled (/metrics:10055)I0817 20:54:58.453692 1 dns.go:147] Starting endpointsControllerI0817 20:54:58.453699 1 dns.go:150] Starting serviceControllerI0817 20:54:58.453841 1 logs.go:41] skydns: ready for queries on cluster.local. for tcp://0.0.0.0:10053 [rcache 0]I0817 20:54:58.453852 1 logs.go:41] skydns: ready for queries on cluster.local. for udp://0.0.0.0:10053 [rcache 0]I0817 20:54:58.964468 1 dns.go:171] Initialized services and endpoints from apiserverI0817 20:54:58.964523 1 server.go:129]
Add Comment