温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Kubernetes node的防火墙问题导致pod ip无法访问该怎么办

发布时间:2021-11-04 16:59:13 来源:亿速云 阅读:232 作者:柒染 栏目:建站服务器

Kubernetes node的防火墙问题导致pod ip无法访问该怎么办,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

环境:
1.在hadoop36机器,ping hadoop38机器的pod的ip,为172.30.1.4
2.该pod的service的external-ip的ip为hadoop36的ip
3.下面机器的ip,已经使用 xx.xx.xx.来替代和加图层覆盖掉

问题:
 无法通过服务EXTERNAL-IP+port,访问对应的pod的服务,说白了,就是无法访问pod ip+port,无法ping通172.30.1.4
Kubernetes node的防火墙问题导致pod ip无法访问该怎么办


步骤:
1.先把服务停掉
[root@hadoop38 ~]#  systemctl stop etcd flanneld docker kubelet kube-proxy

2.查看当前规则,然后清空
[root@hadoop38 ~]#  iptables -L -n

[root@hadoop38 ~]#  iptables -F &&  iptables -X &&  iptables -F -t nat &&  iptables -X -t nat
[root@hadoop38 ~]#  iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@hadoop38 ~]# 


3.重启iptables 和 开启服务
[root@hadoop38 ~]#  systemctl restart iptables
[root@hadoop38 ~]#  systemctl start etcd flanneld docker kubelet kube-proxy

4.再次查看防火墙策略 和清空掉
[root@hadoop38 ~]#  iptables -L -n
[root@hadoop38 ~]#  iptables -F &&  iptables -X &&  iptables -F -t nat &&  iptables -X -t nat

5.等待一会 最终查看防火墙策略 
[root@hadoop38 ~]#  iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
KUBE-FIREWALL  all  --  0.0.0.0/0            0.0.0.0/0           

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
KUBE-FIREWALL  all  --  0.0.0.0/0            0.0.0.0/0           
KUBE-SERVICES  all  --  0.0.0.0/0            0.0.0.0/0            /* kubernetes service portals */


Chain KUBE-FIREWALL (2 references)
target     prot opt source               destination         
DROP       all  --  0.0.0.0/0            0.0.0.0/0            /* kubernetes firewall for dropping marked packets */ mark match 0x8000/0x8000


Chain KUBE-SERVICES (1 references)
target     prot opt source               destination         
[root@hadoop38 ~]#          destination   


6.在36机器验证ping 和 telnet检验
[root@hadoop36 dns]#  kubectl get all -n cdh -o wide
NAME                    READY     STATUS    RESTARTS   AGE       IP           NODE
po/mysql-master-64k8r   1/1       Running   5          1h        172.30.1.4   xx.xx.xx.38

NAME              DESIRED   CURRENT   READY     AGE       CONTAINER(S)   IMAGE(S)                                                SELECTOR
rc/mysql-master   1         1         1         1h        master         hadoop35.jiuye/k8sregister/jiuye/mysql5.6-master:v1.6   name=mysql-master

NAME               CLUSTER-IP      EXTERNAL-IP     PORT(S)     AGE       SELECTOR
svc/mysql-master   10.254.56.245    xx.xx.xx.36   13307/TCP   1h        name=mysql-master
[root@hadoop36 dns]# 

[root@hadoop36 dns]# ping 172.30.1.4
PING 172.30.1.4 (172.30.1.4) 56(84) bytes of data.
64 bytes from 172.30.1.4: icmp_seq=1 ttl=63 time=0.388 ms
^Z
[31]+  Stopped                 ping 172.30.1.4

[root@hadoop36 dns]# telnet   xx.xx.xx.36 13307
Trying  xx.xx.xx..36...
Connected to  xx.xx.xx..36.
Escape character is '^]'


备注:
1.这种情况发生过两次(都是因为vm机器重启),特此记录一下步骤,备查。

看完上述内容,你们掌握Kubernetes node的防火墙问题导致pod ip无法访问该怎么办的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI