You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes集群nslookup kubernetes.default失败求助

Kubernetes DNS解析失败:nslookup kubernetes.default超时,CoreDNS运行正常

我刚搭建完一个单Master单Worker的Kubernetes集群,用的是CentOS 8.2,K8s版本是客户端v1.18.8、服务端v1.18.8。但在测试DNS解析的时候遇到了问题,用dnsutils Pod执行nslookup总是超时,想请大家帮忙排查下。

环境信息

  • 操作系统:CentOS-8.2
  • Kubernetes版本:客户端v1.18.8,服务端v1.18.8

测试用DNS Pod配置

我用以下yaml创建了dnsutils Pod用于测试:

apiVersion: v1
kind: Pod
metadata:
  name: dnsutils
  namespace: default
spec:
  containers:
  - name: dnsutils
    image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3
    command:
      - sleep
      - "3600"
    imagePullPolicy: IfNotPresent
  restartPolicy: Always

集群状态检查

我先检查了集群组件状态,执行kubectl get pods -o wide --all-namespaces后,看到所有组件都运行正常,包括CoreDNS、kube-flannel这些关键组件,没有Crash或者Pending的情况。

故障现象

在Master节点执行以下命令时,nslookup直接超时:

kubectl exec -i -t dnsutils -- nslookup kubernetes.default

错误输出如下:

;; connection timed out; no servers could be reached
command terminated with exit code 1

已完成的配置检查

  1. 检查dnsutils Pod的resolv.conf
    执行kubectl exec -ti dnsutils -- cat /etc/resolv.conf,结果显示nameserver指向kube-dns的ClusterIP(10.96.0.10),搜索域配置也符合预期:
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local company.domain.com
options ndots:5
  1. CoreDNS状态确认
    CoreDNS的Pod运行正常,查看日志没有报错;kube-dns的Service和Endpoints配置都没问题,Endpoints能正确指向CoreDNS Pod的IP。
  2. kubernetes Service检查
    kubernetes Service本身配置正常,Endpoints也正确指向了Master节点的IP。

现在实在找不到问题出在哪了,有没有大佬能帮忙分析下可能的原因?

内容的提问来源于stack exchange,提问作者user4948798

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 23:22:38