Kubernetes nodeport 在侦听主机但服务工作时不可见

问题描述

我在通过 nodeport 公开的 kubernetes 上运行了一个服务,如下所示:

npm uninstall parcel-bundler
npm i -g [email protected]

该服务可以从其他节点访问并且工作正常;但是,如果我执行 test-service NodePort 100.100.246.5 <none> 30005:30005/TCP ,我看不到 kubernetes 正在侦听该端口。

我有 netstat -tunlp | grep 30005,如果我理解正确,这应该意味着上面有 Pod 的节点应该监听所述端口?同样,一切正常,但我想弄清楚为什么我看不到主机上侦听的端口。

解决方法

Kubernetes 服务未实现为侦听特定端口的进程。而是使用 iptables(或 IPVS),服务基本上是 iptables 规则。这就是为什么它们不会出现在您的 netstat 中的原因。您可以在 here 中找到有关它的更多信息。