K8S的1.24.0以上kube-proxy不监听nodeport端口问题

原文地址:K8S的1.24.0以上kube-proxy不监听nodeport端口问题

起因

最近在测试1.24+和1.25+集群时,发现即便 Service 使用 nodeport 暴露,而我在测试1.23.15的时候发现nodeport是正常监听。

github回答

kube-proxy: remove port opener by khenidak · Pull Request #108496 · kubernetes/kubernetes (github.com)

Service NodePorts can be accessed via LB IPs (iptables, at least) · Issue #111863 · kubernetes/kubernetes (github.com)

nodeport Port is not displayed · Issue #115568 · kubernetes/kubernetes (github.com)

说明

github的回答显示,在新版本中已经删除了kube-proxy打开端口套接字部分,但是会在iptables中进行转发,故不影响访问。

阿里云文档说明原因

ACK发布Kubernetes1.24版本说明和解读_容器服务 Kubernetes 版 ACK-阿里云帮助中心

  • Kubernetes 1.24及以后的版本,去除了kube-proxy监听NodePort的逻辑,在NodePort与内核net.ipv4.ip_local_port_range范围有冲突的情况下,可能会导致偶发的TCP无法连接的情况,导致健康检查失败、业务异常等问题。升级前,请确保集群没有NodePort端口与任意节点net.ipv4.ip_local_port_range范围存在冲突。更多信息,请参见Kubernetes社区PR

  • CVE-2022-3172 

验证

[root@node1 ~]# kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:36:36Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/arm64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:29:58Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/arm64"}
[root@node1 ~]# kubectl get svc |grep sen
sentinel        NodePort    10.96.123.120    <none>        8719:30008/TCP,8080:30007/TCP   4d18h
[root@node1 ~]# iptables -S -t nat | grep 30008
-A KUBE-NODEPORTS -p tcp -m comment --comment "default/sentinel:api" -m tcp --dport 30008 -j KUBE-EXT-GTMNQIN2RZFIXRA7
[root@node1 ~]# curl http://127.0.0.1:30008
Invalid command
[root@node1 ~]# 
[root@node1 ~]# netstat -lnpt |grep 30008
[root@node1 ~]# ss -lnpt | grep 30008

验证发现确实可以访问,但是在主机上查不出来,已经不见听nodeport端口了。

以上是个人整合github资料的见解,如有不同看法欢迎留言。

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

llody_55

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值