为什么 Pod 无法连接到另一个网络?(在新版Kubernetes中)

kur*_*kop 7 google-compute-engine google-cloud-platform google-kubernetes-engine

我在 GCP 中有两个项目:

  1. 使用 Kubernetes 节点 v1.8.8-gke.0。以及 Kubernetes 之外但在默认网络中的数据库。所有 pod 都可以连接到此服务器和所有端口
  2. 使用 Kubernetes Nodes v1.9.7-gke.3 和 Kubernetes 之外但在默认网络中的数据库。没有 Pod 可以连接到此服务器。跟踪路由测试失败。

为什么这个 Pod 无法连接?想法?

谢谢。

kur*_*kop 18

我在这里向谷歌报告了这个问题:https : //issuetracker.google.com/issues/111986281

他们说这是 Kubernetes 1.9 中的一个问题:

Beginning with Kubernetes version 1.9.x, automatic firewall rules have changed such that workloads in your Kubernetes Engine cluster cannot communicate with other Compute Engine VMs that are on the same network, but outside the cluster. This change was made for security reasons.

在下一个链接是解决方案:https : //cloud.google.com/kubernetes-engine/docs/troubleshooting#autofirewall

基本上:

首先,找到集群的网络: gcloud container clusters describe [CLUSTER_NAME] --format=get"(network)"

然后获取用于容器的集群的 IPv4 CIDR:

gcloud container clusters describe [CLUSTER_NAME] --format=get"(clusterIpv4Cidr)"

最后为网络创建防火墙规则,以 CIDR 作为源范围,并允许所有协议:

gcloud compute firewall-rules create "[CLUSTER_NAME]-to-all-vms-on-network" --network="[NETWORK]" --source-ranges="[CLUSTER_IPV4_CIDR]" --allow=tcp,udp,icmp,esp,ah,sctp