How can I generate OpenShift/Kubernetes object definitions using parameterized templates with helm or other tools?

7/8/2019

I was wondering if it is possible to use helm charts just to generate the k8s objects themselves.

We are using multiple k8s clusters with managed by openshift.
Helm doesn't work so well with multiple openshift clusters,
so we figured that using the oc would work better (mostly for authentication and authorization on multiple clusters).

Helm dynamic k8s objects are very powerful and we would like to keep using them.
Is it possible to tell helm to generate the object from the given yaml files and values file, and pass them along to oc replace?

-- natdev
kubernetes
kubernetes-helm
openshift
openshift-enterprise
openshift-origin

1 Answer

7/8/2019

OpenShift has its own internal templating engine that overlaps significantly with helm, but is more tightly integrated.

You can find documentation on this in the Templates section of the official OpenShift documentation.

When using these templates you can generate object definitions from a parameterized template by using the oc process command.

$ oc process -f my-rails-postgresql \
    -p POSTGRESQL_USER=bob \
    -p POSTGRESQL_DATABASE=mydatabase

You can create the resulting objects in-line using oc create

$ oc process -f my-rails-postgresql \
    -p POSTGRESQL_USER=bob \
    -p POSTGRESQL_DATABASE=mydatabase \
    | oc create -f -

Personally I find helm to be overkill when using OpenShift as the out-of-the-box templating engine is usually sufficient.

If you need something more sophisticated than that I tend to reach towards packaging my deployment in an ansible playbook, jinja2 templates, and the k8s ansible module instead of running helm and tiller.

-- Nick
Source: StackOverflow