-3

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

在我的 POD 中,我正在执行curl windows_host_ip:4000但无法获得响应。正在建立来自 POD 的连接,但响应超时。 日志

  • 在 DNS 缓存中找不到主机名
  • 正在尝试 192.168.18.10...
  • 连接到 192.168.18.10 端口 4000 失败:连接被拒绝
  • 连接192.168.18.10 4000端口失败:连接被拒绝
  • 关闭连接0 curl:(7)无法连接到192.168.18.10端口4000:连接被拒绝root@ordermanagement-64694dd8b8-2ktm8:/apps/ordermanagement# curl -v http://192.168.18.10:4000/ordermanagement/order/订单
  • 在 DNS 缓存中找不到主机名
  • 正在尝试 192.168.18.10...
  • 连接到 192.168.18.10 (192.168.18.10) 端口 4000 (#0)

GET /ordermanagement/order/orders HTTP/1.1 用户代理:curl/7.38.0 主机:192.168.18.10:4000 接受:/

  • 接收失败:对等方重置连接
  • 关闭连接 0 curl: (56) Recv failure: Connection reset by peer

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

4

1 回答 1

-1

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

您可以考虑为集群内的主机进程创建一个 Kubernetes 端点,请在此处查看此文档以手动管理服务端点

您也可以通过将您的 pod 作为Privileged 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您可以通过将 privileged 标志设置为(默认情况下不允许容器访问主机上的任何设备)将 pod 变成特权 pod 。

于 2021-10-19T07:31:11.450 回答