我在 Google Cloud 上运行虚拟机,并使用他们的 SDK 通过以下命令进行部署:
gcloud preview app deploy ./app.yaml
部署有效,但是对于每个部署都会创建一个新实例,只能通过将版本 ID 添加到域名来访问。我尝试通过开发人员仪表板删除旧实例,但之后它们直接重新启动。
部署时如何删除新建的实例并默认覆盖主域上的默认版本?
最佳答案
要直接从 gcloud
执行此操作,请使用以下两个标志:
--set-default
:Set the deployed version to be the default serving 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.
(均来自 gcloud preview app deploy --help
)。
如果每次都将 --version
设置为相同,则部署在该 URL 的当前版本将被覆盖,并且不会在每次部署时创建新版本。
如果您使用--set-default
,部署的版本可以只使用域名访问(没有版本作为子域)。
在开发者控制台中手动删除其他版本将是摆脱它们的最简单方法。
关于python - Google Cloud VM 在部署时创建新版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31056462/