简体   繁体   English

gcloud beta 运行部署 --source。 抛出 412

[英]gcloud beta run deploy --source . throws 412

Due to corporate restrictions, I'm supposed to host everything on GCP in Europe.由于公司限制,我应该在欧洲托管 GCP 上的所有内容。 The organisation I work for, has set a restriction policy to enforce this.我工作的组织制定了限制政策来执行此操作。

When I deploy a cloud run instance from source with gcloud beta run deploy --source. --region europe-west1当我使用gcloud beta run deploy --source. --region europe-west1 gcloud beta run deploy --source. --region europe-west1 it seems the command tries to store the temporary files in a storage bucket in the us , which is not allowed. gcloud beta run deploy --source. --region europe-west1 us命令似乎试图将临时文件存储在美国的存储桶中,这是不允许的。 The command then throws a 412 error.然后该命令会抛出 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'

I see the Artifact Registry Repository being created in the correct region, but not the storage bucket.我看到在正确的区域中创建了 Artifact Registry Repository,但没有在存储桶中创建。

To bypass this I have to create a storage bucket first in the correct region with the name PROJECT_ID_cloudbuild .为了绕过这个,我必须首先在正确的区域创建一个名为PROJECT_ID_cloudbuild的存储桶。 Is there any other way to fix this?还有其他方法可以解决这个问题吗?

Looking at the error message indicates that the bucket is forced to be created in the US regardless of the Organisation policy set in Europe.查看错误消息表明无论在欧洲设置的组织策略如何,都必须在美国强制创建存储桶。 As per this public issue tracker comment ,根据这个公共问题跟踪评论

“Cloud build submit creates a [PROJECT_ID]_cloudbuild bucket in the US. “云构建提交在美国创建了一个 [PROJECT_ID]_cloudbuild 存储桶。 This will of course not work when resource restrictions apply.当资源限制适用时,这当然不起作用。 What you can do as a workaround is to create that bucket yourself in another location.作为解决方法,您可以做的是在另一个位置自己创建该存储桶。 You should do this before your first cloud build submit.”您应该在首次提交云构建之前执行此操作。”

This has been a known issue and I found two workarounds that can help you achieve what you want.这是一个已知问题,我发现了两个解决方法可以帮助您实现您想要的。

The first workaround is by using “gcloud builds submit” with additional flags:第一个解决方法是使用带有附加标志的“gcloud builds submit”:

  • Create a new bucket with the name [PROJECT_ID]_cloudbuild in the preferred location.在首选位置创建一个名为 [PROJECT_ID]_cloudbuild 的新存储桶。
  • Specify non-buckets using --gcs-source-staging-dir and --gcs-log-dir 2 ===> this flag is required as if it is not set it will create a bucket in the US.使用--gcs-source-staging-dir--gcs-log-dir 2指定非存储桶 ===> 此标志是必需的,因为如果未设置,它将在美国创建一个存储桶。

The second workaround is by using a cloudbuild.yaml and the “--gcs-source-staging-dir” flag:第二种解决方法是使用 cloudbuild.yaml 和“--gcs-source-staging-dir”标志:

  • Create a bucket in the region, dual-region or multi-region you may want在您可能需要的区域、双区域或多区域中创建存储桶
  • Create a cloudbuild.yaml for storing a build artifacts创建一个cloudbuild.yaml用于存储构建工件
  • You can find an example of the YAML file in the following external documentation , please note that I cannot vouch for its accuracy since it is not from GCP.您可以在以下外部文档中找到 YAML 文件的示例,请注意,我无法保证其准确性,因为它不是来自 GCP。
  • Run the command:运行命令:

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

Please try these workarounds and let me know if it worked for you.请尝试这些解决方法,让我知道它是否适合您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gcloud beta 构建触发器运行 - 为什么指定分支名称 - gcloud beta builds triggers run - why specify branch name 错误:(gcloud.beta.functions.deploy)...消息=[调用者没有权限] - ERROR: (gcloud.beta.functions.deploy) ... message=[The caller does not have permission] 当我尝试部署端点配置时,gcloud 抛出 PERMISSION_DENIED - gcloud throws PERMISSION_DENIED when I try to deploy endpoint configuration gcloud 函数部署问题 - gcloud functions deploy issue 为什么运行`gcloud run deploy`,完全按照教程,报错“image must be specified” - Why does running `gcloud run deploy`, exactly according to the tutorial, give the error "image must be specified" 错误:(gcloud.run.deploy) 参数 --set-env-vars:dict arg 的错误语法 - ERROR: (gcloud.run.deploy) argument --set-env-vars: Bad syntax for dict arg `gcloud run deploy` 引发“修订<revision_name>还没有准备好,无法为交通服务。”</revision_name> - `gcloud run deploy` raises "Revision <revision_name> is not ready and cannot serve traffic." (gcloud.run.deploy) 用户提供的容器启动监听失败 - (gcloud.run.deploy) The user-provided container failed to start and listen 使用“gcloud run deploy”时,如何使用命令行参数指定服务名称? - When using 'gcloud run deploy', how can I specify the service name with command line args? airflow 操作员使用 gcloud beta dataproc 命令 - airflow operator to use gcloud beta dataproc commands
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM