首页/云/Kubernetes 速查/NodePort 连通性验证步骤
网络与服务55 条

NodePort 连通性验证步骤

从集群外验证 NodePort 需要按「服务配置 → 后端就绪 → 节点监听 → 防火墙 → 源端路由」顺序排查,避免盲改。

Kubernetes 速查云更新于 2026-10-12

集群侧确认

集群侧确认
kubectl get svc web-np -o wide
kubectl get endpoints web-np
kubectl get pods -l app=web -o wide
kubectl get svc web-np -o jsonpath='{.spec.ports[0].nodePort}'

节点与外部侧确认

节点与外部侧确认
curl -sv http://<节点内网IP>:30080/health
ss -lntp | grep 30080            # 节点上应有监听(kube-proxy 规则)
iptables -t nat -L KUBE-NODEPORTS -n | head
# 云上检查安全组/网络 ACL;本机检查主防火墙
在集群内 curl ClusterIP 通、节点上 curl 不通时,优先看节点防火墙与 kube-proxy 状态。

易错点

  • 用节点外网 IP 测不通但内网通,多半是安全组/公网带宽或运营商策略,不是 K8s 问题
  • NodePort 端口在 kube-proxy 模式下由 iptables/ipvs 规则响应,ss 不显示用户态进程属正常

数据来源与参考

  • Kubernetes 官方文档 · Service(NodePort)/ 集群排障实践
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌