从私有 GKE 集群访问非 gcr 公共容器注册表

swi*_*cks 2 docker google-cloud-platform google-kubernetes-engine

我想在我的私有 GKE 集群中部署 nginx-ingress-controller 映像 ( https://github.com/kubernetes/ingress-nginx ),但我无法提取该映像,因为它位于 quay.io 的注册表中。如何提取不在 GCR 或 GCR Dockerhub 镜像上的公共镜像?

我考虑过将其拉出并上传到我自己的 GCR 注册表,但随后我必须保持更新它。有没有办法保留该图像的私人镜像?

小智 6

私有 GKE 集群中的节点没有外部 IP,默认情况下无法出口到互联网,这就是集群无法从非 GCR 注册表中提取映像的原因。

要允许互联网出站,您需要在 GKE 集群所在的同一项目中启用Cloud NAT 。

gcloud compute routers create nat-router \
    --network custom-network1 \
    --region us-central1

gcloud compute routers nats create nat-config \
    --router-region us-central1 \
    --router nat-router \
    --nat-all-subnet-ip-ranges \
    --auto-allocate-nat-external-ips
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅https://cloud.google.com/nat/docs/gke-example#step_6_create_a_nat_configuration_using 。