OpenShift Templates: Set parameter values with the help of a second file

Latest response

Hey guys,

So I am in the situation where I have an OpenShift Template with a lot of parameters. Depending on the situation and environment I am working with, I would like to set these to different values. Currently I am doing this is by just overwriting them with the "-p" flag when processing the template with the oc command. So for example I would do something like this

Environment 1

oc process -f template-location.yaml -p PARAMETER1=environment1value -p PARAMETER2=environment1value ... | oc create -f -

Environment 2

oc process -f template-location.yaml -p PARAMETER1=environment2value -p PARAMETER2=environment2value ... | oc create -f -

...and so forth for every other environment.

What I would like to know was, whether it is possible to offload the value of these parameters in to a separate file (maybe yaml or json aswell) and read them in from there. So that for example something similar to this is possible (Note: the "-p" switch there is just meant as a stand in):

Environment 1

oc process -f template-location.yaml -p environment1-values.yaml  | oc create -f -

Environment 2

oc process -f template-location.yaml -p environment2-values.yaml  | oc create -f -

Especially from a DevOps perspective this would be really nice, as you could just check-in the value files into VCS as well.

Is there a functionality like this? Or do you guys maybe have an even better idea? Unfortunately I could not find anything in the documentation.

Responses

Oh sorry I was looking at the wrong version of the OpenShift Documentation, actually in the Docs for 3.5, 3.6 it is described in detail. Sorry my bad.

from https://docs.openshift.com/container-platform/3.6/dev_guide/templates.html#templates-parameters: "If you have large number of parameters, you can store them in a file and then pass this file to oc process:"

$ cat postgres.env
POSTGRESQL_USER=bob
POSTGRESQL_DATABASE=mydatabase
$ oc process -f my-rails-postgresql --param-file=postgres.env