在 Google 云 运行 中限制网络 activity
Restrict network activity in Google Cloud Run
我正在使用 Cloud 运行 容器来处理 运行 不受信任的(用户提供的)代码。容器收到一个 POST 请求,运行 代码,并返回结果。出于安全原因,它部署在锁定的服务帐户上,但我也想阻止所有其他网络 activity。如何实现?
Cloud 运行(托管)当前不提供防火墙限制以通过 IP/host 选择性地阻止入站或出站流量。我假设您正在尝试阻止从容器到外部的连接。将来,Cloud 运行 计划添加对 Google Cloud VPC Service Controls 功能的支持,这可能会有所帮助。
但是,如果您有机会使用 Cloud 运行 for Anthos(在 GKE 上),它具有类似的开发人员体验但在 Kubernetes 集群上运行,您实际上可以轻松编写 Kubernetes NetworkPolicy
策略(我在使用 Kubernetes 集群时有一些食谱 here) to control which sort of traffic can come/go from the containers running. You can also use GCE firewall rules and VPC service controls。
除此之外,您在云 运行(完全托管)环境中的唯一选择是在启动容器时使用 Linux iptables
命令来阻止某些网络模式。重要的是,请注意 Cloud 运行(完全托管)在 gVisor sandbox which emulates system calls. And many of the features in iptables
are currently not implemented/supported in gVisor. By looking at issue tracker and patches 上运行,我可以说它在路线图上,有些甚至可能在今天工作。
您可以将云 运行(托管)部署耦合到没有任何互联网访问权限的 VPC Network
。
我正在使用 Cloud 运行 容器来处理 运行 不受信任的(用户提供的)代码。容器收到一个 POST 请求,运行 代码,并返回结果。出于安全原因,它部署在锁定的服务帐户上,但我也想阻止所有其他网络 activity。如何实现?
Cloud 运行(托管)当前不提供防火墙限制以通过 IP/host 选择性地阻止入站或出站流量。我假设您正在尝试阻止从容器到外部的连接。将来,Cloud 运行 计划添加对 Google Cloud VPC Service Controls 功能的支持,这可能会有所帮助。
但是,如果您有机会使用 Cloud 运行 for Anthos(在 GKE 上),它具有类似的开发人员体验但在 Kubernetes 集群上运行,您实际上可以轻松编写 Kubernetes NetworkPolicy
策略(我在使用 Kubernetes 集群时有一些食谱 here) to control which sort of traffic can come/go from the containers running. You can also use GCE firewall rules and VPC service controls。
除此之外,您在云 运行(完全托管)环境中的唯一选择是在启动容器时使用 Linux iptables
命令来阻止某些网络模式。重要的是,请注意 Cloud 运行(完全托管)在 gVisor sandbox which emulates system calls. And many of the features in iptables
are currently not implemented/supported in gVisor. By looking at issue tracker and patches 上运行,我可以说它在路线图上,有些甚至可能在今天工作。
您可以将云 运行(托管)部署耦合到没有任何互联网访问权限的 VPC Network
。