流量无法到达Kubernetes集群中的POD



我有一个本地Kubernetes运行在Windows上使用Docker。在我的Windows主机上,我在端口4000上运行一个进程。

在我的POD中,我执行curl windows_host_ip:4000但没能得到回应。来自POD的连接正在建立,但响应超时。

  • 主机名在DNS缓存中未找到
  • 尝试192.168.18.10…
  • 连接192.168.18.10端口4000失败:Connection refused
  • 连接192.168.18.10端口4000失败:Connection refused
  • 关闭连接0curl:(7)连接192.168.18.10端口4000失败:连接拒绝root@ordermanagement-64694dd8b8-2ktm8:/apps/ordermanagement# curl -v http://192.168.18.10:4000/ordermanagement/order/orders
  • 主机名在DNS缓存中找不到
  • 尝试192.168.18.10…
  • 连接到192.168.18.10端口4000 (#0)

GET/ordermanagement/order/orders HTTP/1.1用户代理:旋度/7.38.0主持人:192.168.18.10:4000接受:/

  • Recv failure: Connection reset by peer
  • 关闭连接0curl: (56) Recv failure: Connection reset by peer

请告诉我如何允许来自主机系统的传入流量到我的POD

这是预期的行为。pod不应该直接访问主机的网络、进程、文件系统等,否则任何人闯入pod都可以获得主机系统的全部信息,还可以获得主机上运行的其他pod的全部信息。

你可以考虑为集群中的主机进程创建一个Kubernetes端点,请参阅这里的文档手动管理服务端点。

您也可以通过将您的pod运行为特权pod来实现这一点,但是,运行特权pod并不是一个好的安全实践。

Privileged - determines if any container in a pod can enable privileged mode. By default, a container is not allowed to access any devices on the host, but a "privileged" container is given access to all devices on the host. This allows the container nearly all the same access as processes running on the host. This is useful for containers that want to use Linux capabilities like manipulating the network stack and accessing devices.

您可以通过将特权标志设置为true(默认情况下容器不允许访问主机上的任何设备)将pod转换为特权pod。

最新更新