【问题标题】:Kubernetes: Unable to hit Pod from MasterKubernetes:无法从 Master 访问 Pod
【发布时间】:2023-04-07 18:36:01
【问题描述】:

我有 1 个 Master 和 2 个 Menions。

Master IP: 192.168.20.50
Menion1: 192.168.20.51
Menion2: 192.168.20.52

我能够在 Master 中运行复制容器并创建服务。我在使用主 IP 访问应用程序容器时遇到问题。

我使用 fallowing 命令进行了从 master 到 menion 的端口转发。

[root@master ~]# kubectl port-forward nginx :80 &
[2] 2229
[root@master ~]# I1201 22:15:46.822396 2229 portforward.go:213] Forwarding from 127.0.0.1:43020 -> 80
I1201 22:15:46.822603 2229 portforward.go:213] Forwarding from [::1]:43020 -> 80

所以当我点击 localhost 时,我可以访问 nginx,但是当我点击 Master IP 时,连接被拒绝。

[root@master ~]# curl http://localhost:43020
I1201 22:15:57.031858 2229 portforward.go:247] Handling connection for 43020

<title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style>
Welcome to nginx!

如果您看到此页面,则 nginx Web 服务器已成功安装并正在运行。需要进一步配置。

有关在线文档和支持,请参阅 nginx.org。 nginx.com 上提供商业支持。

感谢您使用 nginx。

[root@master ~]# curl http://192.168.1.49:43020
curl: (7) Failed connect to 192.168.1.49:43020; Connection refused

【问题讨论】:

  • 您使用的是特定的覆盖网络吗?您的机器是否可通过 IP 转发?

标签: kubernetes


【解决方案1】:

您将 Pod 流量转发到端口 80,您应该能够到达该 pod

192.168.1.49:80

不是

192.168.1.49:43020

【讨论】:

  • 是的,我试过 192.168.1.49:80。它也不起作用。谢谢
  • 我意识到这不是您节点的 IP。您尝试的是 Node IP,而不是 Pod IP?
  • 节点 IP 运行良好。不知道为什么我在做端口远写时无法击中大师
猜你喜欢
  • 2020-07-06
  • 2019-05-03
  • 2019-05-08
  • 1970-01-01
  • 2015-06-06
  • 2021-06-24
  • 2020-04-12
  • 2022-01-15
相关资源
最近更新 更多