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:
You can override
manifest.yml
settings withcf
cli arguments. Thus you could put an instance count of one into yourmanifest.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 youcf push
that overrides the value frommanifest.yml
with the value you set as the cli argument. Ex:cf push -i <override>
.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'serb
(or any other template engine) to make some dynamic adjustments and then use the output to deploy your app.Don't use
manifest.yml
at all. Instead just use a shell script and a composition ofcf
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.
- 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.
- 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.