2019-06-03 15:22:47 -04:00
// Module included in the following assemblies:
//
2020-02-17 09:02:34 +10:00
// * applications/application_life_cycle_management/creating-applications-using-the-cli.adoc
2019-06-03 15:22:47 -04:00
2019-09-18 01:10:14 +05:30
[id="applications-create-using-cli-template_{context}"]
2019-06-03 15:22:47 -04:00
= Creating an application from a template
You can create an application from a previously stored template or from a
template file, by specifying the name of the template as an argument. For
example, you can store a sample application template and use it to create an
application.
2020-08-06 14:09:31 +01:00
Upload an application template to your current project's template library. The following example uploads an application template from a file called `examples/sample-app/application-template-stibuild.json`:
2019-06-03 15:22:47 -04:00
2020-08-06 14:09:31 +01:00
[source,terminal]
2019-06-03 15:22:47 -04:00
----
$ oc create -f examples/sample-app/application-template-stibuild.json
2020-08-06 14:09:31 +01:00
----
Then create a new application by referencing the application template. In this example, the template name is `ruby-helloworld-sample`:
[source,terminal]
----
2019-06-03 15:22:47 -04:00
$ oc new-app ruby-helloworld-sample
----
2020-08-06 14:09:31 +01:00
To create a new application by referencing a template file in your local file system, without first storing it in {product-title}, use the `-f|--file` argument. For example:
2019-06-03 15:22:47 -04:00
2020-08-06 14:09:31 +01:00
[source,terminal]
2019-06-03 15:22:47 -04:00
----
$ oc new-app -f examples/sample-app/application-template-stibuild.json
----
== Template Parameters
When creating an application based on a template, use the
`-p|--param` argument to set parameter values that are defined by the template:
2020-08-06 14:09:31 +01:00
[source,terminal]
2019-06-03 15:22:47 -04:00
----
$ oc new-app ruby-helloworld-sample \
-p ADMIN_USERNAME=admin -p ADMIN_PASSWORD=mypassword
----
2020-08-06 14:09:31 +01:00
You can store your parameters in a file, then use that file with `--param-file` when instantiating a template. If you want to read the parameters from standard input, use `--param-file=-`. The following is an example file called `helloworld.params`:
2019-06-03 15:22:47 -04:00
2020-08-06 14:09:31 +01:00
[source,terminal]
2019-06-03 15:22:47 -04:00
----
ADMIN_USERNAME=admin
ADMIN_PASSWORD=mypassword
2020-08-06 14:09:31 +01:00
----
Reference the parameters in the file when instantiating a template:
[source,terminal]
----
2019-06-03 15:22:47 -04:00
$ oc new-app ruby-helloworld-sample --param-file=helloworld.params
----