我正在尝试在 200 个奇怪的端口上公开服务。这是示例服务 yaml:
apiVersion: v1
kind: Service
metadata:
name: multiport-server-large-port
spec:
type: NodePort
selector:
app: multiport-server-large-port
ports:
- port: 49152
name: tcp-49152
- port: 49153
name: tcp-49153
- port: 49154
name: tcp-49154
- port: 49155
name: tcp-49155
- port: 49156
name: tcp-49156
- port: 49157
name: tcp-49157
- port: 49158
.
.
.
.... 200 more such ports
应用此 yaml 后,会创建服务,但由于ip:port
连接被拒绝错误,无法访问该组合。经过进一步调查,我发现 iptables 过滤器链 KUBE-EXTERNAL-SERVICES 中有一些 REJECT 条目用于我暴露的端口。
IPTABLES 拒绝规则:
Chain KUBE-EXTERNAL-SERVICES (1 references)
pkts bytes target prot opt in out source destination
0 0 REJECT tcp -- any any anywhere anywhere /* default/multiport-server-large-port:tcp-49316 has no endpoints */ ADDRTYPE match dst-type LOCAL tcp dpt:31
184 reject-with icmp-port-unreachable
0 0 REJECT tcp -- any any anywhere anywhere /* default/multiport-server-large-port:tcp-49325 has no endpoints */ ADDRTYPE match dst-type LOCAL tcp dpt:31
225 reject-with icmp-port-unreachable
0 0 REJECT tcp -- any any anywhere anywhere /* default/multiport-server-large-port:tcp-49383 has no endpoints */ ADDRTYPE match dst-type LOCAL tcp dpt:32
620 reject-with icmp-port-unreachable
0 0 REJECT tcp -- any any anywhere anywhere /* default/multiport-server-large-port:tcp-49385 has no endpoints */ ADDRTYPE match dst-type LOCAL tcp dpt:30
107 reject-with icmp-port-unreachable
0 0 REJECT tcp -- any any anywhere anywhere /* default/multiport-server-large-port:tcp-49359 has no endpoints */ ADDRTYPE match dst-type LOCAL tcp dpt:31
我想了解:
- 为什么会出现这些 REJECT 规则?
- 这不可能通过服务公开大量端口吗?
- 可以通过服务公开的端口数量是否有限制?