【问题标题】:gcloud beta run deploy --source . throws 412gcloud beta 运行部署 --source 。抛出 412
【发布时间】:2022-03-02 15:59:38
【问题描述】:

由于公司限制,我应该在欧洲的 GCP 上托管所有内容。我工作的组织制定了限制政策来强制执行。

当我使用gcloud beta run deploy --source . --region europe-west1 从源部署云运行实例时,该命令似乎试图将临时文件存储在us 的存储桶中,这是不允许的。然后该命令会引发 412 错误。

➜ gcloud beta run deploy cloudrun-service-name --source . --platform managed --region=europe-west1 --allow-unauthenticated
This command is equivalent to running `gcloud builds submit --tag [IMAGE] .` and `gcloud run deploy cloudrun-service-name --image [IMAGE]`

Building using Dockerfile and deploying container to Cloud Run service [cloudrun-service-name] in project [PROJECT_ID] region [europe-west1]
X Building and deploying new service... Uploading sources.                                                                                                                                                                                                      
  - Uploading sources...                                                                                                                                                                                                                                        
  . Building Container...                                                                                                                                                                                                                                       
  . Creating Revision...                                                                                                                                                                                                                                        
  . Routing traffic...                                                                                                                                                                                                                                          
  . Setting IAM Policy...                                                                                                                                                                                                                                       
Deployment failed                                                                                                                                                                                                                                               
ERROR: (gcloud.beta.run.deploy) HTTPError 412: 'us' violates constraint 'constraints/gcp.resourceLocations'

我看到 Artifact Registry Repository 正在正确的区域中创建,但不是存储桶。

要绕过这个,我必须首先在正确的区域中创建一个名为 PROJECT_ID_cloudbuild 的存储桶。有没有其他方法可以解决这个问题?

【问题讨论】:

  • @maercky 我在下面发布了一个答案。请仔细阅读解决方案,尝试一下,看看您是否遇到任何问题。回复反馈。
  • 嗨@PriyashreeBhadra,感谢您的回复。正如您所说明的那样,显然还有其他解决方法(为此-谢谢!),但我认为不是内置的“干净”解决方案。

标签: google-cloud-platform google-cloud-run


【解决方案1】:

查看错误消息表明,无论在欧洲设置的组织政策如何,都强制在美国创建存储桶。按照这个public issue tracker comment

“云构建提交会在 我们。当资源限制适用时,这当然不起作用。 作为一种解决方法,您可以做的是自己创建该存储桶 另一个位置。您应该在您的第一个云构建之前执行此操作 提交。”

这是known issue,我发现了两种解决方法可以帮助您实现您想要的。

第一个解决方法是使用带有附加标志的“gcloud builds submit”:

第二种解决方法是使用 cloudbuild.yaml 和“--gcs-source-staging-dir”标志:

gcloud 构建提交 --gcs-source-staging-dir="gs://example-bucket/cloudbuild-custom" --config cloudbuild.yaml

请尝试这些解决方法,如果它对您有用,请告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-07
    • 1970-01-01
    • 2020-03-25
    • 1970-01-01
    • 1970-01-01
    • 2021-09-16
    • 2019-03-03
    • 1970-01-01
    相关资源
    最近更新 更多