Specific configuration per space in manifest.yml

拈花ヽ惹草 提交于 2019-12-23 02:16:46

问题


Is there a way to set a manifest.yml property for a specific space, e.g. if I want to have 5 instances of my service when deploying to the production space but having only 1 for all other spaces?


回答1:


A few options come to mind:

  1. You can override manifest.yml settings with cf cli arguments. Thus you could put an instance count of one into your manifest.yml file (actually, you don't need to do this because one is the default value but you can put any value in the file) and when you cf push that overrides the value from manifest.yml with the value you set as the cli argument. Ex: cf push -i <override>.

  2. There's no conditional logic available in an app's manifest.yml, but there's nothing stopping you from using a template language with your manifest. You could, for example, run a templated manifest.yml through Ruby's erb (or any other template engine) to make some dynamic adjustments and then use the output to deploy your app.

  3. Don't use manifest.yml at all. Instead just use a shell script and a composition of cf cli commands and arguments. It's a little more work to get going, but you get all the dynamic behavior of a shell script. Actually, it doesn't have to be a shell script. You could use Python or Ruby or insert your favorite scripting language here.

Probably not exactly the answer you were hoping for here, but hope that it helps.




回答2:


Depending on the deployment tool, you can parameterise the instances. For ex: in IBM Urban Code Deploy (UCD), you can declare number of instances as a component environment property and you can given different values for each space. DEV, QA can have 1 and PROD can have 5.

There are multiple ways to use this property.

  1. Add the below entry in manifest.yml

instances: ${instance_count}

Value of instance_count parameter can be configured per Space in Urban Code Deploy. I'm sure you can do this with Concourse or other deployment tools also.

  1. Use the parameter in the cf push command.

Urban Code Deploy and other tools run the cf push command to push the application. In the push command, you can give -i parameter and use the instance_count variable which will substitute the value depending on the space to which you are pushing.

You can use the first method to parameterise several fields such as memory, log level etc which can have different values for different spaces.



来源:https://stackoverflow.com/questions/46191898/specific-configuration-per-space-in-manifest-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!