简体   繁体   English

在云代工厂 cf push 命令中有没有办法让 manifest.yml 有几个“配置文件”?

[英]Is there a way in cloud foundry cf push command to have a manifest.yml with several "profiles"?

We have different setups (deployment parameters) for prod and for non prod environments, in regards to memory, instances etc.对于生产环境和非生产环境,我们有不同的设置(部署参数),包括内存、实例等。

We are deploying our applications with Jenkins pipeline, on Pivotal Cloud Foundry environments, which is eventually calling a script with a "CF push" command.我们正在使用 Jenkins 管道在 Pivotal Cloud Foundry 环境中部署我们的应用程序,最终使用“CF push”命令调用脚本。

We are examining using two different manifest.yml files (but dislike the duplicity if identical parameters).我们正在检查使用两个不同的manifest.yml文件(但不喜欢相同参数的重复性)。 We are also examining using --var-file with two different vars files.我们还在检查将--var-file与两个不同的 vars 文件一起使用。 We have a concern with backward compatibility, and the effort (we have many MSs) of adding so many files.我们担心向后兼容性,以及添加如此多文件的努力(我们有很多 MS)。

We want a manifest.yml that will look like this:我们想要一个manifest.yml看起来像这样:

applications:
- name: myAppName
  services:
  - discovery
  - config-server
profile:
  dev:
    memory: 1024M
    instances: 1
  prod:
    memory: 4096M
    instances: 4

Assuming we will need to pass a parameter profile=dev to the cf push command is fine.假设我们需要将参数profile=dev传递给cf push命令就可以了。

In DEV environment 1 instance with 1024M of memory will be deployed;在DEV环境中,将部署1个1024M内存的实例; while in PROD environments, 4 instances with 4096M of memory will be deployed.而在 PROD 环境中,将部署 4 个具有 4096M 内存的实例。

I suggest that you reconsider using variables in your manifest.我建议您重新考虑在清单中使用变量。 You can use --var-file , but if you want to avoid having those files present you can just pass in multiple --var=<name>=<val> arguments instead.您可以使用--var-file ,但如果您想避免出现这些文件,您可以改为传入多个--var=<name>=<val>参数。

That or just have dev.yml and prod.yml files, you can then cf push -f dev.yml or cf push -f prod.yml and pick between the two.或者只有dev.ymlprod.yml文件,然后您可以cf push -f dev.ymlcf push -f prod.yml并在两者之间进行选择。 There's a little duplication, but the files are tiny so it shouldn't be a big deal.有一点重复,但文件很小,所以应该没什么大不了的。

Hope that helps!希望有帮助!

I don't think, trying to achieve everything using CF CLI commands is the right way to do我不认为,尝试使用 CF CLI 命令来实现一切是正确的方法

I would achieve this much simply by writing a bash script and executing cf-push sequencely in whichever fashion I would like to have..我将通过编写一个 bash 脚本并以我想要的任何方式依次执行 cf-push 来实现这一目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM