Search code examples
openshiftopenshift-origin

Openshift oc params-file format


I want to provide a different set of parameters to an openshift template depending on the specific deployment. I have been using

oc new-app -f my-template.yml -p P1="p1-override-value" -p P2="p2-override-value" ...

However, the list of parameter overrides on the command line is getting very long and unwieldy. The oc CLI has an option available, "--param-file=" that presumably solves my problem, but nowhere can I find what the expected yaml (or JSON) format should be. Can someone that has used param-files in openshift provide a sample param-file please?


Solution

  • Its very simple. Create a file say test.env and have a key value pairs for your parameters. Ex:

    BUILD_IMAGE_PREFIX=test.xyz.com:5000
    BUILD_IMAGE_TAG=:latest
    

    In your teamplate.yaml file externalize the values you want to use from env file. Ex: image: ${BUILD_IMAGE_PREFIX}/abc${BUILD_IMAGE_TAG}

    Now, deploy the dc in openshift using below command:

    oc process --param-file=test.env -f test.yaml | oc create -f -