k8s 中mysql 无法访问_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

473546abd41d2916f3538babf7bc0e2e.png

步骤:

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]#telnetxx.xx.xx.36 13307

Tryingxx.xx.xx..36...

Connected toxx.xx.xx..36.

Escape character is '^]'

备注:

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值