google-cloud-platform - 使用 --allow-unauthenticated

我的目标是使用 Cloud Build 部署 Cloud Functions。我的 cloudbuild.yaml 如下所示:

steps:
- name: gcr.io/cloud-builders/gcloud
  args: 
    [
      'functions', 'deploy', 'func3',
      '--region=us-central1',
      '--allow-unauthenticated',
      '--entry-point=helloWorld',
      '--runtime=nodejs8',
      '--source=https://source.developers.google.com/projects/XXX/repos/myfunc',
      '--trigger-http',
      '--service-account=XXX@appspot.gserviceaccount.com'
    ]

当我提交构建时,会记录以下内容:

Created [https://cloudbuild.googleapis.com/v1/projects/XXX/builds/5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa].
Logs are available at [https://console.cloud.google.com/gcr/builds/5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa?project=YYY].
------------------------------------------------------------------------------------ REMOTE BUILD OUTPUT ------------------------------------------------------------------------------------
starting build "5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa"

FETCHSOURCE
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
ERROR: (gcloud.functions.deploy) unrecognized arguments: --allow-unauthenticated 

To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/gcloud" failed: exit status 2
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.builds.submit) build 5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa completed with status "FAILURE"

如我们所见,我们失败了。如果我删除引用 --allow-unauthenticated 的行,所有操作都会正确进行。为了完整起见,这里是工作 cloudbuild.yaml

steps:
- name: gcr.io/cloud-builders/gcloud
  args: 
    [
      'functions', 'deploy', 'func3',
      '--region=us-central1',
      '--entry-point=helloWorld',
      '--runtime=nodejs8',
      '--source=https://source.developers.google.com/projects/XXX/repos/myfunc',
      '--trigger-http',
      '--service-account=XXX@appspot.gserviceaccount.com'
    ]

我检查了关于 gcloud functions deploy 的 gcloud 文档,发现 here并且看不到任何拼写错误或其他微不足道的错误。我一直假设将 gcloud 作为 Cloud Builder 步骤运行与手动运行它是一样的。

如果我手动运行命令(包括 --allow-unauthenticated),它可以正常运行。例如,如果我运行:

#!/bin/bash
gcloud functions deploy func3 \
    --region=us-central1 \
    --allow-unauthenticated \
    --entry-point=helloWorld \
    --runtime=nodejs8 \
    --source=https://source.developers.google.com/projects/XXX/repos/myfunc \
    --trigger-http \
    --service-account=XXX@appspot.gserviceaccount.com

...没有问题。

问题的核心是 Cloud Build 上下文中的 --allow-unauthenticated 选项可能有什么问题?

最佳答案

这似乎是由错误的 gcloud 构建镜像引起的暂时性问题。

暂时使用这个版本:

gcr.io/cloud-builders/gcloud@sha256:4ea77d19d7336d5a8dc4ae0e609d7f5b45fca067c34b70d7ed6740af229392c6

关于google-cloud-platform - 使用 --allow-unauthenticated 从 Cloud Build 部署 Cloud Functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58897847/

相关文章:

leaflet - 校正 Rayshader 的卫星图像覆盖

python - 如何使用需要使用 MLflow 的二维以上输入形状的模型进行预测?

react-native - 从选项卡导航选项卡打开抽屉导航

java - 如何设置不需要凭据的 Localstack 容器?

javascript - 单击通知打开已安装的 PWA

gradle - pivotal/LicenseFinder 为 Gradle 项目返回 "No d

android-studio - 为什么我只看到官方 android 类的反编译源代码?

apache-spark - 使用来自 s3 存储桶的数据在 AWS EMR 上使用 pyspark

javascript - 如何使用 ngx-export-as 中的选项

linux - Podman (libpod) 在使用 SELinux 上下文挂载 shm 时无法运