Google cloud platform GKE节点的Internet连接

Google cloud platform GKE节点的Internet连接,google-cloud-platform,google-kubernetes-engine,gke-networking,Google Cloud Platform,Google Kubernetes Engine,Gke Networking,我使用以下命令创建了一个GKE集群: gcloud container clusters create experiment --num-nodes=1 --network default --subnetwork default --enable-private-nodes --enable-private-endpoint --enable-ip-alias --master-ipv4-cidr 172.16.0.16/28 --no-enable-basic-auth --no-issue

我使用以下命令创建了一个GKE集群:

gcloud container clusters create experiment --num-nodes=1 --network default --subnetwork default --enable-private-nodes --enable-private-endpoint --enable-ip-alias --master-ipv4-cidr 172.16.0.16/28 --no-enable-basic-auth --no-issue-client-certificate 
我的VPC防火墙中没有出口规则 我在VPC routes下有一个自动创建的默认路由,该路由应用于GKE节点并允许互联网访问

在GKE节点上,我可以:

    $ docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
bb79b6b2107f: Pull complete 
111447d5894d: Pull complete 
a95689b8e6cb: Pull complete 
1a0022e444c2: Pull complete 
32b7488a3833: Pull complete 
Digest: sha256:ed7f815851b5299f616220a63edac69a4cc200e7f536a56e421988da82e44ed8
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest



docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
6a5697faee43: Pull complete 
ba13d3bc422b: Pull complete 
a254829d9e55: Pull complete 
Digest: sha256:fff16eea1a8ae92867721d90c59a75652ea66d29c05294e6e2f898704bdb8cf1
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
但我不能:

$ wget https://www.amazon.com
--2020-10-31 19:22:44--  https://www.amazon.com/
Resolving www.amazon.com... 13.226.21.44
Connecting to www.amazon.com|13.226.21.44|:443... 
但我可以:

  $ wget https://www.google.com
--2020-10-31 19:23:15--  https://www.google.com/
Resolving www.google.com... 172.217.212.147, 172.217.212.99, 172.217.212.106, ...
Connecting to www.google.com|172.217.212.147|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: 'index.html.1'
index.html.1                                   [ <=>                                                                                    ]  12.48K  --.-KB/s    in 0s      
2020-10-31 19:23:15 (72.1 MB/s) - 'index.html.1' saved [12782]





   route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.128.0.1      0.0.0.0         UG    1024   0        0 eth0
10.108.2.0      0.0.0.0         255.255.255.0   U     0      0        0 cbr0
10.128.0.1      0.0.0.0         255.255.255.255 UH    1024   0        0 eth0
169.254.123.0   0.0.0.0         255.255.255.0   U     0      0        0 docker0
$ wget https://www.google.com
$wgethttps://www.google.com
--2020-10-31 19:23:15--  https://www.google.com/
正在解析www.google.com。。。172.217.212.147, 172.217.212.99, 172.217.212.106, ...
连接到www.google.com | 172.217.212.147 |:443。。。有联系的。
HTTP请求已发送,正在等待响应。。。200行
长度:未指定[text/html]
保存到:“index.html.1”
index.html.1[]12.48K--.-KB/s,0秒
2020-10-3119:23:15(72.1MB/s)-“index.html.1”已保存[12782]
路线-n
内核IP路由表
目标网关Genmask标志度量参考使用Iface
0.0.0.0 10.128.0.1 0.0.0.0 UG 10240 0 eth0
10.108.2.0 0.0.0.0 255.255.255.0 U 0 0 0 cbr0
10.128.0.1 0.0.0.0 255.255.255 UH 1024 0 0 eth0
169.254.123.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0
GKE节点上的internet连接发生了什么变化。我可以到达docker hub但不能?这里有点混乱

GKE节点上的internet连接发生了什么变化。我够得着 码头中心,但不是?这里有点混乱

我知道乍看起来可能有点困惑,因为您可能认为您确实可以访问。嗯,事实上你没有

你试过卷曲吗https://hub.docker.com/?我想你没有。如果你这样做了,你会注意到它也失败了

正如你所看到的:

专用群集中的节点没有对公共群集的出站访问权限 互联网。他们对谷歌API和服务的访问有限, 包括容器注册

那么,这里到底发生了什么事?

您不是直接从中提取图像,而是从它的镜像中提取图像,由Google容器注册表维护。你可以用一种非常简单的方法来检查它。如果你拉
nginx
(相当于
nginx:latest
),它工作得很好,但是如果你试着拉
nginx:1.14.2
,它会失败。这是因为,GCR没有在Docker Hub上保留所有图像的旧版本。在以下文件中也提到了这一点:

无法直接从Docker Hub获取图像。相反,使用图像 托管在容器注册表上。注意,当容器注册表 如果可以从专用群集访问,则不应以独占方式访问 依靠。镜像只是一个缓存,因此图像会定期更新 已删除,并且专用群集无法回退到Docker Hub

我在不久前的回答中对其进行了深入的解释,所以您可能也想看一看。这在本文中也有很好的解释

但我可以:

  $ wget https://www.google.com
--2020-10-31 19:23:15--  https://www.google.com/
Resolving www.google.com... 172.217.212.147, 172.217.212.99, 172.217.212.106, ...
Connecting to www.google.com|172.217.212.147|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: 'index.html.1'
index.html.1                                   [ <=>                                                                                    ]  12.48K  --.-KB/s    in 0s      
2020-10-31 19:23:15 (72.1 MB/s) - 'index.html.1' saved [12782]





   route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.128.0.1      0.0.0.0         UG    1024   0        0 eth0
10.108.2.0      0.0.0.0         255.255.255.0   U     0      0        0 cbr0
10.128.0.1      0.0.0.0         255.255.255.255 UH    1024   0        0 eth0
169.254.123.0   0.0.0.0         255.255.255.0   U     0      0        0 docker0
$ wget https://www.google.com

来吧,你在GCP平台上,POD(GKE节点)需要访问构建内部运行的容器所需的内容。看起来Google只允许这种资源,比如dockerhub和它们的地址空间(在CDN后面可能有容器注册),它们阻止了其他一切。这就是你不能打开亚马逊网站的原因。@Iñigo你说的有道理。谢谢但要寻找更明确、更正式的方法。在您的防火墙端口443上添加允许外部访问规则