gcloud应用程序部署'--appyaml'标志似乎不起作用 [英] gcloud app deploy '--appyaml' flag doesn't seem to work

查看:111
本文介绍了gcloud应用程序部署'--appyaml'标志似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Google App Engine,我想在部署后将env_variables注入我的app.yaml中.在gcloud app deploy的文档中,我看到有一个标志--appyaml将:

For Google App Engine, I want to inject env_variables into my app.yaml upon deploy. In the docs for gcloud app deploy, I see that there is the flag --appyaml that will:

使用特定的app.yaml进行部署,它将替换DEPLOYABLE中定义的app.yaml.

Deploy with a specific app.yaml that will replace the one defined in the DEPLOYABLE.

https://cloud.google.com/sdk/gcloud/reference /app/deploy

所以我有一个Fabric脚本,该脚本读取我的app.yaml,注入我的额外env变量,将此新的app.yaml写入一个临时文件,然后运行gcloud app deploy. gcloud的命令最终看起来像这样:

So I have a Fabric script that reads my app.yaml, injects my extra env variables, writes this new app.yaml to a tempfile, and then runs gcloud app deploy. The command to gcloud ends up looking like this:

gcloud app deploy . --version dev --project myproject --appyaml='/var/folders/1z/qk45g9p934lg75byl8b74xyh0000gn/T/tmpgdjVUG.yaml'

部署成功并且上传了新代码,但是我的新env变量似乎没有弥补.

The deploy succeeds and new code gets uploaded, however my new env variables don't seem to make it up.

如果我向--appyaml提供虚假值,则会引发错误,因此它似乎确实使用了我的输入.

If I provide a bogus value to --appyaml then it throws an error, so it does seem to use my input.

有什么主意我可能做错了吗?

Any ideas what I could be doing wrong?

推荐答案

我已经在标准AppEngine上对其进行了测试,并在node.JS中进行了小的HelloWorld修改,如下所示:

I have tested it on standard AppEngine with small HelloWorld modification in node.JS like this:

'use strict';

const express = require('express');
const app = express();

app.get('/', (req, res) => {
    var my_respond = "variables: ";
    res.status(200).send(Object.entries(process.env)).end();
});

const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});

module.exports = app;

该示例将环境变量显示为结果.

The sample is showing environment variables as result.

比我添加的最简单的app.yaml:

runtime: nodejs10
env_variables:
  MY_VAR: "my value from app.yaml"

除了在其他位置,我还添加了另一个名为app1.yamlyaml:

Than in other location I have added different yaml called app1.yaml:

runtime: nodejs12
env_variables:
  MY_VAR: "my value from app1.yaml"

因此,这正在更改节点版本和MY_VAR的值.

So this is changing node version and value of MY_VAR.

根据我的测试,这似乎与文档中解释的工作方式略有不同,至少我的理解有所不同.

According to my tests this seems to be working little bit differently than explained in the doc, at least I understand it differently.

可以使用--appyaml标志,但是仅当目录中没有app.yaml文件时才可以使用.如果您没有在应用程序目录中使用它,则可以使用该标志指向其他yaml.

It's possible to use --appyaml flag, but only when there is no app.yaml file in the directory. If you do not have it in app directory, than using the flag you can point to different yaml.

因此,当我尝试使用gcloud app deploy --appyaml="/home/vitooh/app1.yaml"进行部署并且app.yaml在应用程序目录中时,该应用程序即随其进行了部署-因此该标志不会执行任何操作.但是,当我在没有app.yaml的情况下完成该标志时,变量值就会更改.

So when I was trying to deploy with gcloud app deploy --appyaml="/home/vitooh/app1.yaml" and app.yaml was in application directory, the app was deployed with it - so the flag does not do anything. However when I done it without app.yaml the flag works, variable value is changed.

实际上,您可以在提交命令后发现该摘要,并在确认部署之前以descriptor值的形式发现它,如下所示:

Actually you can spot it just after submitting command where there is a summary shown, just before you confirm deployment, in descriptor value like this:

descriptor:      [/home/vitooh/app1.yaml]
source:          [/home/vitooh/appEngine/nodejs-docs-samples/appengine/hello-world/standard]
target project:  [xxxxx-test-01]
target service:  [default]
target version:  [20200819t094956]
target url:      [https://xxxxx-test-01.appspot.com]

Do you want to continue (Y/n)?

这篇关于gcloud应用程序部署'--appyaml'标志似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆