为什么NodePort类型的service在 node节点上 netstat看不到其nodeport端口?

作者站长头像
站长
· 阅读数 10

为什么NodePort类型的service在 node节点上 netstat看不到其nodeport端口?为什么NodePort类型的service在 node节点上 netstat看不到其nodeport端口?NodePort类型的service 的nodePort为31002


apiVersion: v1
kind: Service
metadata:
  name: tomcat-service
spec:
 type: NodePort
 ports:
  - port: 8080
    nodePort: 31002
 selector:
    tier: frontend

问题: 虽然curl localhost:31002 能返回html数据,但是为什么 netstat -tlp |grep 31002 没有数据?

回复
1个回答
avatar
test
2024-06-19

这个端口是通过 iptable 规则转发到实际的服务 pod ip/端口 上去的,并没有一个进程在这个端口上监听。所以 netstat 自然就看不到。

回复
likes
适合作为回答的
  • 经过验证的有效解决办法
  • 自己的经验指引,对解决问题有帮助
  • 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
  • 询问内容细节或回复楼层
  • 与题目无关的内容
  • “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容