如何在不计费的情况下在灵活的环境中部署 GAE 项目?

How to deploy a GAE project in flexible environment without billing?

我一直在使用 Flask 和其他第三方库开发一些 REST 服务,我想将它部署到灵活环境中的 GAE。我通常部署到 GAE 标准环境,但我想尝试新的灵活环境。目前我希望在不启用计费的情况下部署到灵活的环境,Google 支持向我保证可以在不启用计费的情况下通过 GAE 灵活的环境进行部署。

运行 我的代码在本地工作正常,并且有以下 yaml 文件:

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT whereismybus230.starter:app

runtime_config:
  python_version: 3

所以我通过 Google 云控制台网页(像往常一样)创建了一个新项目,并在我的本地机器上创建了一个新的 gcloud 配置文件,所以我将它部署到这个新项目。 然后我运行:

gcloud app deploy --verbosity=info

我知道正在构建一个 docker 图像,在某个时候它会被推送到计算引擎,但它在几分钟后失败了:

Successfully built sophiabus230 aniso8601 future docopt itsdangerous MarkupSafe
Installing collected packages: Werkzeug, click, MarkupSafe, Jinja2, itsdangerous, Flask, jsonschema, pytz, six, python-dateutil, aniso8601, flask-restplus, beautifulsoup4, future, sophiabus230, coverage, requests, docopt, coveralls
Successfully installed Flask-0.12 Jinja2-2.9.4 MarkupSafe-0.23 Werkzeug-0.11.15 aniso8601-1.2.0 beautifulsoup4-4.5.3 click-6.7 coverage-4.3.4 coveralls-1.1 docopt-0.6.2 flask-restplus-0.9.2 future-0.16.0 itsdangerous-0.24 jsonschema-2.5.1 python-dateutil-2.6.0 pytz-2016.10 requests-2.12.5 six-1.10.0 sophiabus230-0.4
 ---> 3e3438680079
Removing intermediate container bd9f8ccb6f4a
Step 8 : ADD . /app/
 ---> bde0915f6720
Removing intermediate container e3193eb4ef70
Step 9 : CMD gunicorn -b :$PORT whereismybus230.starter:app
 ---> Running in 022d38d769f8
 ---> 36893d0a549a
Removing intermediate container 022d38d769f8
Successfully built 36893d0a549a
PUSH
The push refers to a repository [us.gcr.io/whereismy230/appengine/default.20170120t131841]
e5f488ee94c5: Preparing
8d27ce27f03c: Preparing
3d5800d45c36: Preparing
06ba8a2a8ec3: Preparing
c0fb81dae3c6: Preparing
2e4eabdbeed3: Preparing
b5d474284f52: Preparing
c307273999be: Preparing
d73750730c30: Preparing
63bbaf04cf0b: Preparing
badb9b2d625b: Preparing
40c928fd4dcc: Preparing
dfcf8dbe47e1: Preparing
6d820e13990c: Preparing
2e4eabdbeed3: Waiting
b5d474284f52: Waiting
c307273999be: Waiting
d73750730c30: Waiting
63bbaf04cf0b: Waiting
badb9b2d625b: Waiting
40c928fd4dcc: Waiting
dfcf8dbe47e1: Waiting
6d820e13990c: Waiting
denied: Unable to create the repository, please check that you have access to do so.
The push refers to a repository [us.gcr.io/whereismy230/appengine/default.20170120t131841]
...
ERROR: (gcloud.app.deploy) Error Response: [2] Build failed; check build logs for details

使用IAM服务,我确定我的账户是项目的所有者,甚至检查了所有权限。 由于灵活的环境依赖于计算引擎 (VM),我尝试从网页上进行检查,它告诉我需要启用计费才能使用此功能。

我做错了什么吗? 谢谢!

来自 App Engine Pricing:

Instances within the standard environment have access to a daily limit of resource usage that is provided at no charge defined by a set of quotas. Beyond that level, applications will incur charges as outlined below. To control your application costs, you can set a spending limit. To estimate costs for the standard environment, use the pricing calculator.

Go to the pricing calculator

For instances within the flexible environment, services and APIs are priced as described below.

来自Flexible environment instances

Applications running in the App Engine flexible environment are deployed to virtual machine types that you specify. This table summarizes the hourly billing rates of the various computing resources:

US
Resource  Unit    Unit cost
vCPU  per core hour   [=10=].0526
Memory    per GB hour     [=10=].0071
Persistent disk   per GB per month    [=10=].0400

与标准环境不同,弹性环境没有免费配额。这符合您的观察,即开发人员控制台需要为 运行 GAE flex 实例启用计费。

如果不启用计费功能,您可能能够部署您的应用程序(但实际上并没有为它启动 GAE 实例,所以不确定它的用处,因为您想尝试一下)通过使用 --no-promote 选项:

--promote

Promote the deployed version to receive all traffic.

True by default. To change the default behavior for your current environment, run:

  $ gcloud config set app/promote_by_default false

Overrides the default promote_by_default property value for this command invocation. Use --no-promote to disable.

旁注:当您遇到问题时,您可能还想使用 --verbosity=debug 来获取有关故障的更多相关信息。