content_image/707955.jpg content_image/707956.jpg content_image/707957.jpg
## OpenShift Templates 

Templates are regular resource descriptors that are parameterized. As seen in Example 20-7, we can easily use the configuration image as a parameter. 

apiVersion : v1 kind : Template metadata : name : demo parameters : - name : CONFIG_IMAGE description : Name of configuration image value : k8spatterns/config-dev:1 objects : - apiVersion : v1 kind : DeploymentConfig // .... spec: template : metadata : // .... spec: initContainers : - name : init image : ${CONFIG_IMAGE} args : [ "/config" ] volumeMounts : - mountPath : /config name : config-directory containers : - image : k8spatterns/demo:1 // ... volumeMounts : - mountPath : /config name : config-directory volumes : - name : config-directory emptyDir : {} 

Template parameter CONFIG_IMAGE declaration 

<img src='content_image/707955.jpg'>

Use of the template parameter 

<img src='content_image/707956.jpg'>

<img src='content_image/707957.jpg'>

We show here only a fragment of the full descriptor, but we can quickly recognize the parameter CONFIG_IMAGE  we reference in the init container declaration. If we create this template on an OpenShift cluster, we can instantiate it by calling oc , as in Example 20-8. 

