GCP Cloud Run:无法创建服务

2024-03-31

我正在尝试将 Cloud run 与私有 GKE 集群结合使用。 我使用以下命令创建了集群:

gcloud beta container clusters create cluster-name \
    --create-subnetwork name=cloud-run-subnet \
    --enable-master-authorized-networks \
    --enable-ip-alias \
    --enable-private-nodes \
    --enable-private-endpoint \
    --master-ipv4-cidr 172.16.0.32/28 \
    --no-enable-basic-auth \
    --no-issue-client-certificate \
    --addons=HorizontalPodAutoscaling,HttpLoadBalancing,Istio,CloudRun \
    --machine-type=n1-standard-1 \
    --enable-stackdriver-kubernetes \
    --scopes cloud-platform \
    --zone us-central1-a

我在同一 VPC 和子网中创建了一台堡垒主机,可以使用以下命令联系该集群:

gcloud compute instances create bastion \
 --zone us-central1-a \
 --subnet cloud-run-subnet \
 --machine-type=g1-small \
 --scopes cloud-platform

我在堡垒主机上安装了 kubectl 并使用以下命令将上下文切换到该集群gcloud container clusters get-credentials命令。

我使用以下命令确保在默认命名空间上启用了 Istio:

kubectl label namespace default istio-injection=enabled

现在,当我尝试使用以下命令部署服务时,出现错误:

gcloud beta run deploy hello \
    --image=gcr.io/projectname/hello-world \
    --platform=gke \
    --cluster=cluster-name \
    --cluster-location=us-central1-a \
    --connectivity=internal

Error:

ERROR: (gcloud.beta.run.deploy) Error:                                                                                                                                                                             
failed calling webhook "webhook.serving.knative.dev": Post https://webhook.knative-serving.svc:443/?timeout=30s: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting he
aders)

我尝试过两者--connectivity=internal and --connectivity=external我犯了同样的错误。

当我尝试使用控制台创建服务时,出现以下错误:

Failed to create a service

Tracking number: d123456789

我已确保为容器注册表保留相同的项目(gcr.io)和 GKE 集群。

确切的事情在公共集群上运行得很好。 我无法找到具体文档来使其全部与私有 GKE 集群一起使用。我有什么遗漏的吗? 我做错了什么吗?


在此 GitHub 线程中修复了类似的问题:

https://github.com/knative/serving/issues/4868 https://github.com/knative/serving/issues/4868

主要原因是在私有GKE集群中,默认情况下只有GKE Master可以访问端口443或80的服务。


您可以尝试使用该端口吗8443而不是443,并将端口列入白名单8443.

https://cloud.google.com/kubernetes-engine/docs/how-to/private-clusters#add_firewall_rules https://cloud.google.com/kubernetes-engine/docs/how-to/private-clusters#add_firewall_rules

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GCP Cloud Run:无法创建服务 的相关文章

随机推荐