gcloud app deploy 不会删除以前的版本 [英] gcloud app deploy does not remove previous versions

查看:23
本文介绍了gcloud app deploy 不会删除以前的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Google App Engine 上运行 Node.js 应用,使用以下命令部署我的代码:

I am running a Node.js app on Google App Engine, using the following command to deploy my code:

gcloud app deploy --stop-previous-version

我想要的行为是终止所有运行以前版本的实例,但它们似乎总是存在.有什么我遗漏的吗?

My desired behavior is for all instances running previous versions to be terminated, but they always seem to stick around. Is there something I'm missing?

我意识到他们没有收到流量,但我仍在为他们付费,他们会造成一些背景遥测噪音.有没有更好的方法来运行这个命令?

I realize they are not receiving traffic, but I am still paying for them and they cause some background telemetry noise. Is there a better way of running this command?

gcloud 应用实例列表 的示例输出:如您所见,我运行了两个不同的版本.

Example output of the gcloud app instances list: As you can see I have two different versions running.

推荐答案

我们意外地在不到 30 天的时间内耗尽了我们的免费 G​​oogle App Engine 积分,因为后续部署没有清除一个错误的灵活实例.当我们将其确定为原因时,它已扩展到四个基本上处于空闲状态的同时发生的实例.

We accidentally blew through our free Google App Engine credit in less than 30 days because of an errant flexible instance that wasn't cleared by subsequent deployments. When we pinpointed it as the cause it had scaled up to four simultaneous instances that were basically idling away.

tl;dr: 在部署时使用 --version 标志来指定版本名称.具有相同版本的现有实例将是替换然后下次部署时.

tl;dr: Use the --version flag when deploying to specify a version name. An existing instance with the same version will be replaced then next time you deploy.

这让我陷入了--stop-previous-version 的陷阱.以下是我目前发现的:

That led me down the rabbit hole that is --stop-previous-version. Here's what I've found out so far:

--stop-previous-version 似乎不再受支持.它在 gcloud app deploy 的 Flags 下提到 参考页面,但是如果您查看列出所有标志的页面顶部,则无处可寻.

--stop-previous-version doesn't seem to be supported anymore. It's mentioned under Flags on the gcloud app deploy reference page, but if you look at the top of the page where all the flags are listed, it's nowhere to be found.

我尝试使用该标志进行部署,看看会发生什么,但似乎没有效果.还是新建了一个版本,我还是要进去手动删除旧实例.

I tried deploying with that flag set to see what would happen but it seemingly had no effect. A new version was still created, and I still had to go in and manually delete the old instance.

gcloud-maven-plugin repo 明确指出这是该插件的问题,但该问题似乎已被忽略.

There's an open Github issue on the gcloud-maven-plugin repo that specifically calls this out as an issue with that plugin but the issue has been seemingly ignored.

此时我们最好的选择是将 --version=staging 或任何内容添加到 gcloud deploy app.该标志的参考文档似乎表明它将替换共享该版本"的现有实例:

At this point our best bet at this point is to add --version=staging or whatever to gcloud deploy app. The reference docs for that flag seem to indicate that that it'll replace an existing instance that shares that "version":

--version=VERSION, -v 版本

--version=VERSION, -v VERSION

此部署将创建或替换的应用版本.如果您不指定版本,则会为您生成一个.

The version of the app that will be created or replaced by this deployment. If you do not specify a version, one will be generated for you.

(强调我的)

此外,Google 自己的 关于 app.yaml 的参考文档(Python 文档的链接,但它仍然相关)特别将 --version 标志称为首选"标志.部署时指定版本的方法:

Additionally, Google's own reference documentation on app.yaml (the link's for the Python docs but it's still relevant) specifically calls out the --version flag as the "preferred" way to specify a version when deploying:

推荐的方法是从您的 app.yaml 文件中删除 version 元素,而是使用命令行标志来指定您的版本 ID

The recommended approach is to remove the version element from your app.yaml file and instead, use a command-line flag to specify your version ID

这篇关于gcloud app deploy 不会删除以前的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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