适用于多种环境的Google Cloud App Engine app.yaml [英] Google Cloud App Engine app.yaml for multiple environments

查看:188
本文介绍了适用于多种环境的Google Cloud App Engine app.yaml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前已启动并运行我的应用, app.yaml dispatch.yaml 位于根目录的应用程序,我通过Google Cloud CLI进行部署。

目前这种做法很好,但是当我开始使用 dev 时, staging prod 环境我可以看到它不再可行。



我看到的主要问题是我必须编辑 app.yaml 文件中的变量,以便它们是适用于环境(例如我使用 env_variables 来存储mysql凭证...)。

我不能在文档中找到任何指向正确的方式来管理这个,任何想法的东西?

另外...从GIT仓库部署时,似乎 app.yaml 需要位于回购,这是正确的吗?这对我来说不太合适......必须有更好的方法!注意:假设你使用不同的应用程序来实现每个环境,而不是不同的服务/模块的同一个应用程序,哪个恕我直言将是一个不必要的复杂。请参阅如何将一个应用程序引擎应用程序部署到多个项目



我个人对每种环境都使用不同的git分支。



当然,我只有2个环境:开发/暂存和生产环境,但同样的原则适用:

分支结构反映了流经环境:


  • master 分支用于 dev 环境

  • 分段分支被拉下 master 分支
  • 生产分支从 staging 分支



要将代码更改从一个环境传播到另一个环境,分支到更新的父分支版本(其中包含您想要提取的更改),并将合并的子分支代码部署到相应的环境。



每个分支都有自己的分支版本的 app.yaml 文件。你必须留意这个文件中的冲突,当它的变化从一个分支传播到另一个分支时,这个冲突可能会弹出。

另见 Google App Engine Java中的环境特定变量 (也许是它的链接/相关帖子)。


I currently have my app up and running, the app.yaml and dispatch.yaml are in the root of the application and I deploy through Google Cloud CLI.

This works well for the moment, though as I move to having a dev, staging and prod environment I can see that it's no longer viable.

The main issue I see is that I have to edit the variables in the app.yaml file so they are appropriate for environment (for example I use env_variables to store mysql credentials...).

I can't find anything in the docs that points to the correct way to manage this, any ideas?

Also... When deploying from a GIT repo it seems that the app.yaml needs to be in the repo, is this correct? It doesn't seem right to me... There must be a better way!

解决方案

Note: assuming you use a different application to implement each environment, not different services/module of the same application, which IMHO would be an unnecessary complication. See How to deploy one app engine app to multiple projects

Personally I use a different git branch for each environment.

Granted I only have 2 environments: a development/staging one and the production one, but the same principle applies:

The branch structure reflects the flow through environments:

  • the master branch is used for the dev environment
  • the staging branch is pulled off the master branch
  • the production branch is pulled off the staging branch

To propagate code changes from one environment to another you'd merge the respective child branch to the newer parent branch version (which contains the changes you want to pick up) and deploy the merged child branch code to the corresponding environment.

Each branch has its own version of the app.yaml file. You'll have to keep an eye on conflicts in this file which may pop up whenever changes to it are propagated from one branch to another.

See also Environment Specific Variables In Google App Engine Java (and maybe its linked/related posts).

这篇关于适用于多种环境的Google Cloud App Engine app.yaml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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