[英]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”:
The second workaround is by using a cloudbuild.yaml and the “--gcs-source-staging-dir” flag:第二种解决方法是使用 cloudbuild.yaml 和“--gcs-source-staging-dir”标志:
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.