Openshift templates are Openshift’s answer to Kubernetes helm charts. In this way, an openshift template contains a list of objects. In consequence, applying an openshift template substitutes its placeholders. Also, it contains a parameter list. Openshift template are a built-in feature of Openshift. But what are differences to helm?

How does Openshift Template work?

 

Openshift Template

apiVersion: v1
kind: Template
metadata:
  name: redis-template
  name: REDIS_PASSWORD
labels:
  redis: master
objects:
- apiVersion: v1
  kind: Pod
  metadata:
    name: redis-master
  spec:
    containers:
    - env:
      - name: REDIS_PASSWORD
        value: ${REDIS_PASSWORD}
      image: dockerfile/redis
      name: master
      ports:
      - containerPort: 6379
        protocol: TCP
parameters:
- description: Password used for Redis authentication
  from: '[A-Z0-9]{8}'
  name: REDIS_PASSWORD
  generate: expression
Openshift templates are pretty simple. The header introduces the template “> “> (line 1+). The objects section (line 8+) defines a list of cluster objects. Objects may contain placeholder in curly brackets (see line 17). Section of parameters (line 23+) defines parameters to substitute such placeholders. In this example the template requires a parameter REDIS_PASSWORD. The parameters section supplies it.

applying on openshift template

oc process -f template.yaml --param REDIS_PASSWORD=secret

oc process -f template.yaml --param REDIS_PASSWORD=secret | oc create -f -

oc process -f template.yaml --param REDIS_PASSWORD=secret | ec applay -f -
Once openshift template is defined it must be applied to the cluster. The process command (1) reads the template and substitutes parameters and writes results to console. Piping output to “oc create” (3) lets cluster create the new objects. Once created, objects are updated by “oc apply” (5) command.

Openshift Templates versus Helm Charts?

Are Openshift Templates better than Helm charts? There is no easy answer. Notably, Openshift templates are a built-in feature. In contrast, helm requires tiller service installed. Tiller service creates cluster objects. Because of this, Tiller services require cluster-admin permission on Kube-system service account. But for security reasons, most production systems does not grant this permission. Read here for more details.

Conclusion

Templates offer a generic mechanism to deploy applications to different environments. The process of defining a template substitutes environment specific values. Text files may store substitutions. Such text files may be applied to process command.

References:

 

New: OKD Docker Image is stuck – Operation not possible

Openshift and also OKD Docker image is stuck when loading. A severe bug in the CRI-O engine causes stuck the OKD Docker images in an invalid and unusable state. There are discussions about timeouts while loading the images from the docker registry or too long...

Windows Subsystem for Linux and Minikube

The Windows Subsystem for Linux is the seamless integration of Linux into Windows. Use Windows natively and quickly issue a Linux command. Apply a Linux command to the Windows file system without having to start a virtual machine. As a result, Linux is always...

New: Openshift OKD causes image layer not known problems

The POD fails to start, and referrers to the image layer not known. The "layer not known" issue may affect one or more cluster nodes. In effect, there is a corrupt docker image on the local disk cache. The layer not known problem still exists, even after a node or...

The Docker daemon configuration files

Where are the Docker daemon configuration files located? How to restart the Docker daemon after applying changes to the configuration? How to change and activate the Docker configuration? These are frequently asked questions. But changes to the Docker configuration...

Make it easy: Apache Spark, Data Frames and Regex Power

Regular Expressions are a powerful tool to split texts into fragments. Furthermore, Apache Spark is an analytics engine and capable of processing large amounts of data sets. The feature of naming capturing groups makes the usage of regular expressions more accessible....