master节点上的nodeport端口不通(k8s踩坑)
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
问题描述
创建了一个nodeport类型的service,端口是80,按道理来说会在每个节点上开启80端口,但是发现master节点上没有开启80端口,node1、node2上均开启了80端口。
在k8s 1.22.17
版本中已经无法使用lsof -i:80 或netstat -lntup| grep 80
等方式查看service开启的nodeport端口了,但是我们可以使用telnet命令进行测试
问题排查
排查防火墙selinux,都是关闭状态的。
安装网上说的添加:iptables -P FORWARD ACCEPT
,仍是未解决。
查看当初安装集群时配置的开启ipv4转发,也没啥问题:
[root@master glusterfs]# cat /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1
net.ipv4.ip_forward=1
vm.swappiness=0
[root@master glusterfs]#
最后,查看kube-proxy的模式发现是iptables,命名之前已经设置为ipvs了,怎么变成iptables了:
[root@master ~]# curl 127.0.0.1:10249/proxyMode
iptables
[root@master ~]#
查看kube-proxy的pod日志,发现有大量报错:
最终解决
#重新设置 kube-proxy 为ipvs模式
kubectl edit cm kube-proxy -n kube-system
#删除pod,让它重新创建
kubectl delete pod kube-proxy-977sk kube-proxy-t6cbg kube-proxy-v4c8j -n kube-system
#telnet测试
[root@node2 ~]# telnet 192.168.158.128 80 #终于可以正常telnet通master节点上的nodeport端口了
Trying 192.168.158.128...
Connected to 192.168.158.128.
Escape character is '^]'.




A beautiful web dashboard for Linux
最近提交(Master分支:7 个月前 )
186a802e
added ecosystem file for PM2 5 年前
5def40a3
Add host customization support for the NodeJS version 5 年前
更多推荐
所有评论(0)