Kubernetes node的防火墙问题导致pod ip无法访问

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云防火墙,500元 1000GB
简介: 环境: 1.在hadoop36机器,ping hadoop38机器的pod的ip,为172.30.1.4 2.该pod的service的external-ip的ip为hadoop36的ip3.
环境:
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




步骤:
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机器重启),特此记录一下步骤,备查。
目录
相关文章
|
6月前
|
Kubernetes Ubuntu Windows
【Azure K8S | AKS】分享从AKS集群的Node中查看日志的方法(/var/log)
【Azure K8S | AKS】分享从AKS集群的Node中查看日志的方法(/var/log)
169 3
|
6月前
|
存储 网络协议 安全
【Azure 环境】ARM部署模板大于4MB的解决方案及Linked Template遇见存储账号防火墙无法访问
【Azure 环境】ARM部署模板大于4MB的解决方案及Linked Template遇见存储账号防火墙无法访问
|
4月前
|
网络安全 Docker 容器
【Bug修复】秒杀服务器异常,轻松恢复网站访问--从防火墙到Docker服务的全面解析
【Bug修复】秒杀服务器异常,轻松恢复网站访问--从防火墙到Docker服务的全面解析
251 0
|
6月前
|
存储 Kubernetes 负载均衡
在K8S中,node数量增多会有什么影响吗?
在K8S中,node数量增多会有什么影响吗?
|
6月前
|
存储 网络安全 数据中心
【Azure 存储服务】App Service 访问开启防火墙的存储账号时遇见 403 (This request is not authorized to perform this operation.)
【Azure 存储服务】App Service 访问开启防火墙的存储账号时遇见 403 (This request is not authorized to perform this operation.)
103 0
【Azure 存储服务】App Service 访问开启防火墙的存储账号时遇见 403 (This request is not authorized to perform this operation.)
|
6月前
|
JavaScript
NodeJs——无法使用内网IP访问
NodeJs——无法使用内网IP访问
86 1
|
6月前
|
存储 安全 API
【Azure API Management】实现在API Management服务中使用MI(管理标识 Managed Identity)访问启用防火墙的Storage Account
【Azure API Management】实现在API Management服务中使用MI(管理标识 Managed Identity)访问启用防火墙的Storage Account
|
6月前
|
JavaScript Linux 容器
【Azure 应用服务】NodeJS项目部署在App Service For Linux环境中,部署完成后应用无法访问
【Azure 应用服务】NodeJS项目部署在App Service For Linux环境中,部署完成后应用无法访问
|
6月前
|
JavaScript 前端开发 API
揭秘Node.js如何轻松访问API:一个示例足以改变你的开发视角!
【8月更文挑战第21天】在现代Web开发中,API是软件间通信的关键。Node.js以其高效性,在API访问上独具优势。本文通过示例展示如何用Node.js访问API。首先确保已安装Node.js,然后使用npm安装`axios`库。创建`api_example.js`文件,并编写代码以访问JSONPlaceholder API获取数据。成功时,响应数据会输出至控制台;若失败,则打印错误。此示例展示了Node.js结合`axios`访问API的便捷性及高效性,为初学者提供快速入门指南。
60 0
|
6月前
|
Kubernetes 容器
Kubernetes(K8S) 安装 Metrics-Server kubectl top (metrics-server) node NotFound
Kubernetes(K8S) 安装 Metrics-Server kubectl top (metrics-server) node NotFound
75 0

热门文章

最新文章