部署 Google 的 App Engine flex [nginx 示例] 时出错

Error deploying Google's App Engine flex [nginx example]

我正在尝试 deploy Google's nginx hello world example 通过 App Engine 的灵活环境。我使用的设置与快速入门指南中详述的设置相同,但添加到 app.yaml(文件内容如下)的网络设置除外:

runtime: custom
env: flex
network:
  name: my_network
  subnetwork_name: my_subnet

对于复制,我的确切过程是(来自 GCP 云 shell):

  1. 克隆 Google's example repo,
  2. cd进入nginx目录,
  3. 更新 app.yaml 以反映正确的网络设置(见上文),
  4. 运行 gcloud app deploy .gcloud beta app deploy ..

结果是错误13:

53db376e88c7: Layer already exists
3baebd9b50ad: Layer already exists
1401df2b50d5: Layer already exists
57a9a0cdd450: Layer already exists
latest: digest: sha256:96324cd5dd0571fa98e461ecfc844cefc74c1bad7d621273f11f94e7676cde86 size: 2605
DONE
----------------------------------------------------------------------------------------------------
Updating service [default] (this may take several minutes)...failed.                                                                                                       
ERROR: (gcloud.app.deploy) Error Response: [13] An internal error occurred.

我尝试使用不同的健康检查选项进行部署,但收到以下信息:

ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: Legacy health checks are no longer supported for the App Engine Flexible environment. Please remove the 'health_check' section from your app.yaml and configure updated health checks. For instructions on migrating to split health checks see https://cloud.google.com/appengine/docs/flexible/java/migrating-to-split-health-checks

我认为这样做的建议已经过时了。

应用程序本身 运行 在 docker 容器中很好。欢迎任何建议

我也尝试重现您提到的相同场景,但没有向我抛出任何错误。将网络添加到您的 app.yaml 时,您必须确保使用网络的简称,here.

中提到了这一点

您 app.yaml 中的网络设置应如下所示:

network:
  instance_tag: TAG_NAME
  name: NETWORK_NAME
  subnetwork_name: SUBNETWORK_NAME
  session_affinity: true
  forwarded_ports:
    - PORT
    - HOST_PORT:CONTAINER_PORT
    - PORT/tcp
    - HOST_PORT:CONTAINER_PORT/udp

name 的位置:

Every VM instance in the flexible environment is assigned to a Google Compute Engine network when it is created. Use this setting to specify a network name. Give the short name, not the resource path (for example, default rather than https://www.googleapis.com/compute/v1/projects/my-project/global/networks/default). If you do not specify a network name, instances are assigned to the project's default network (which has the name default). If you want to specify a subnetwork name, you must specify a network name.

对于subnetwork_name

Optional. You can segment your network and use a custom subnetwork. Ensure that the network name is specified. Give the short name, not the resource path (for example, default rather than https://www.googleapis.com/compute/v1/projects/my-project/global/networks/default/subnetworks/default).The subnetwork must be in the same region as the application.

如果您正在为您的项目使用 VPC 共享网络,这将帮助您做到这一点,您需要做的就是按照给定的步骤一步步进行 here

Google 支持提供了一个对我有用的解决方案。不过Error 13比较笼统所以YMMV。在您的部署环境中,运行 如下:

  1. gcloud config set interactive/hidden true
  2. gcloud app update --service-account=PROJECT_DEFAULT_APP_ENGINE_SA
  3. gcloud app deploy

1 exposes hidden commands/flags 和 2 设置应用程序的活动服务帐户。

当心 - 项目的默认 App Engine SA 获得大量许可,因此可能值得将 App Engine 隔离到其自己的项目以最大限度地降低风险。